New to PowerShell, but loving the fact that I can do so much so fast :)
In any case, I run the remote process in a PowerShell script as follows:
$compname = "MY-PC" $myinstallcmd = "c:\install\myprog.exe /s" $proc = Invoke-WmiMethod -class Win32_Process -name Create -ArgumentList ($myinstallcmd) -ComputerName $compname
On most computers I tried, the Invoke-WmiMethod cmdlet works fine, but it hangs on one PC. What I'm looking for now is to get the status of a running process, and if it hangs up, kill it and write it to kill, and then go.
I found a possible method for this in the message Starting the process remotely in Powershell, getting% ERRORLEVEL% on Windows - however, when I try to do Register-WmiEvent in the $ proc.ProcessId process, I get the terrible error 0x80070005 (E_ACCESSDENIED) ... I am running PowerShell host as a domain administrator.
Can anyone suggest a way that I can get status in the process that I started and be able to take action based on the status?
Thanks!
source share