Actually you don’t need a loop. Invoke-Command can take an array of computer names.
Regardless of that … since $DCs is still an array of objects and not strings you should use $DCs.Name to specifically access the name property of the object.
If you’re running Invoke-Command against a remote computer, then you DO NOT specify -ComputerName on the cmdlet being run remotely. You’re basically remoting to a system and trying to connect remotely to another system (even if it’s the same system.) Always remember if it has a -ComputerName parameter, that is generally indicating a remote connection.
Also, don’t slow the code down exponentially by looping a command that can take an array of targets.
This is how I typically run it and then inspect $errs for any failures. Keep in mind, the way you’re currently outputting the Get-Hotfix command, nothing will be returned if the specified KB is not found. If you want to ensure an object is always returned, you can use something like this.
if the error says one ore more computer names are invalid, that means one or more items in the $DCS variable is invalid, just for debugging execute the same foreach and print the name before invoke-command .
Foreach($DC in $DCS){
Write-Output "Current DC is [$DC]"
# invoke-command
}
above print message will show the computer name in [], look for any special char or space.