Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

get-wmiobject - the rpc server is unavailable - timeout issue

$
0
0

Hi,

I am doing a WMI query within my script, and random servers keep timing out and jumping into the CATCH portion of the Try/Catch and not every time I run it either.

Try {
$Service = Get-WmiObject -Class Win32_Service -ComputerName $Computer -EnableAllPrivileges -ErrorAction Stop | Select Caption, State, PathName | ? {$_.PathName -like "*sqlservr.exe*" -and $_.Caption -notlike "*$*" -and $_.Caption -notlike "*#*"}
}
Catch{
write-host "WMI Connection Failed   $error[0]"

However after the script finishes, I test these servers' WMI and it responds.

Turns out the failure is due to a Timeout. WMI querry takes too long and powershell drops it with The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) Timeout expired.

Is there any way to extend the timeout period of the query?

 

Thank you,

Russ

 

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles