Remote command call hangs synchronously
I am using a library System.Management.Automation
to invoke PowerShell commands using Remote Runspace. So I create a PowerShell object and call the script as such:
var remoteRunspace = RunspaceFactory.CreateRunspace(wsmanConnectionInfo);
remoteRunspace.Open();
var powershell = PowerShell.Create();
var powershell.Runspace = remoteRunspace;
string PsScript = "Some long running powershell script"
powershell.AddScript(PsScript);
powerShell.Invoke();
The selected call gets stuck and sometimes fails (e.g. 1 in 100 times where we saw this thread get stuck for over 24 hours). If we restart the remote computer, it will appear.
How do we fix this behavior? Is this a known issue in PowerShell? If so, will it work asynchronously PowerShell.BeginInvoke
? My guess is that it should improve some reliability since it will queue per thread ThreadPool
.
source to share
No one has answered this question yet
Check out similar questions: