Run the command and getting the below Error Mgs, can you help how could I skip the error and more further and create the separate file with failed servers
@Get@()
Get-HotFix -ComputerName $Ser -Id kbXXXXX -ErrorAction SilentlyContinue -ErrorVariable err | select HotfixID, Description, InstalledOn, CSName| Sort-Object InstalledOn |
ConvertTo-Csv -NoTypeInformation | Out-File "xxx.csv"
*Error Mgs*
Get-HotFix : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:1 char:1
+ Get-HotFix -ComputerName $Ser -Id kbXXXXXX -ErrorAction SilentlyContinue -Error ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-HotFix], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.GetHotFixCommand
We don't know what is stored in your variable $ser but I literally just had this same problem. I know this was answered in comments suggestion to use a for loop. Tossing in another answer.
In my case I was importing a csv list and looping through. For my computername variable I forgot to append the CSV column name so powershell gets just the value of the servername. Powershell was trying to resolve the entire object as the servername.
So for example:
Get-HotFix -ComputerName $Ser.Name
User contributions licensed under CC BY-SA 3.0