none
PowerShell: Get the hotfix from all the Domain Controllers in a Multi-Domain or Forest Environment (PS Remoting)

    Question

  • My requirement is to get the Hotfix report from all the domain controllers in the Forest (Multi Domain / multi forest environment).

    Current issue I am not getting the report from the servers in the child domain

    #Script Starts here

    $allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }
    $name1 = $allDCs.hostname

    $SessionName1 = New-PSSession -ComputerName ( $name1)

    Invoke-Command -Session $SessionName1 -ScriptBlock {

    Get-HotFix | where {$_.InstalledOn -gt (get-date).AddDays(-5)} | Select Description,Hotfixid,Installedby,@{l="Installed-On";e{[DateTime]::Parse($_.psbase.properties["Installedon"].value,$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}

    } -AsJob

    $ResultJob1 = get-job 
    $ReceiveJob1 = $ResultJob1 |Receive-Job -Wait 
    $ReceiveJob1 | ConvertTo-Html -Property PSComputerName, HotFixID, InstalledBy, Installed-On -Title "Hotfix Report" -PostContent "Report Generated Successfully " -Verbose | Set-Content ".\Report.html"
    Invoke-Expression .\Report.html
    where{$_.entrytype -eq"Error"} 
    $ResultJob1| Stop-Job


    Shinish Sasidharan



    Tuesday, December 20, 2016 3:03 PM

All replies

  • Hi,

    >>Current issue I am not getting the report from the servers in the child domain

    Test this line:

    ((Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }).hostname

    to see if you could get the required child domain name.

    It worked on my environment, getting the correct result.

    Note: Firewall settings on child domain, e.g. RPC services port and etc.

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, December 21, 2016 6:25 AM
    Moderator