02 March 2018

Get-WmiObject hangs

for some reason Get-WmiObject hangs on some of the computers that is queryes and the powershell console must be restarted.

in order to overcome this problem a used "-AsJob" parameter


$Job = Get-WmiObject -Class win32_computersystem -AsJob -ComputerName ServerName | Wait-Job -Timeout 30
$Result = $Job | Receive-Job

No comments:

Post a Comment