Want if kb is installed across all DCs

I have this code

$DCs = [DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() |
        Select-Object -ExpandProperty DomainControllers |
            Select-Object -ExpandProperty Name

###Get kb status all DCs ###			
Invoke-Command -ComputerName $DCs {
    Get-HotFix -Id KB5013941 -ComputerName $DCs
   
}

But my error is . The argument is null or empty. Provide an argument that is not null or empty.

I want to find out if a recent kb got installed on all DCs (It’s a problem patch MS released this month if you’re using NPS/Radius servers)

thanks

You’re invoking command on $DCs, you don’t also want to put $DCs on get-HotFix

1 Like

I replaced with

$_.
$_.name
<null>

still see errors. What should replace the $DCs, then?

Jeff,

I am unable to test this but it looks like you are unable to get the variable to pass through to the scriptblock. I would recommend trying something like this.

$DCs = [DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() |
        Select-Object -ExpandProperty DomainControllers |
            Select-Object -ExpandProperty Name

###Get kb status all DCs ###
Foreach ($DC in $DCS){		
    Invoke-Command -ComputerName $DC {
        Get-HotFix -Id KB5013941 -ComputerName $using:DC    
    }
}

thank you tbingeman. Never saw use of that $using env before

Actually you don’t need to specify the parameter -ComputerName inside the script block of Invoke-Command when you already specified the parameter -ComputerName outside of it. :wink:

1 Like