I have seen that error code when the value of the -computer parameter is incorrect (no computer with that name exists).
Since you have the computer name in a variable $computer, try a simple ping $computer
and see if the name is resolved, machine exists, is reachable etc.
"IT Staff" wrote:
[Quoted Text] > When i run my script in the cmd prompt, it gives the following error : > > Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: > 0x80070 > 6BA) > At D:\PowerShell\scripts\kb.ps1:11 char:16 > + $checkkb = gwmi <<<< Win32_QuickFixEngineering -computer $computer | > where { > $_.hotfixid -eq $kb} | select-object hotfixid > > > ============================================================ > > function CheckWMI ($computer,$kb) > { > > $checkkb = gwmi Win32_QuickFixEngineering -computer $computer | where > {$_.hotfixid -eq $kb} | select-object hotfixid > > if ($checkkb.hotfixid -eq $kb) > > { write-host -f green $computer "" $checkkb.hotfixid } > > else > > { write-host -f red $computer " Not found."} > > } > > cls > $computernames = get-content "D:\POWERSHELL\SCRIPTS\COMPUTERS.txt" > > foreach ($computer in $computernames) > { > $kb = "KB935839" > checkwmi($computer,$KB) > } > > > >
|