C# 使用WinRM在目标计算机上同时运行PowerShell命令
我正在尝试在目标计算机上同时远程运行多个PowerShell命令C# 使用WinRM在目标计算机上同时运行PowerShell命令,c#,.net,powershell,C#,.net,Powershell,我正在尝试在目标计算机上同时远程运行多个PowerShell命令 var connectionInfo = new WSManConnectionInfo(); var runspacePool = RunspaceFactory.CreateRunspacePool(1, 10, connectionInfo); runspacePool.Open(); var waitHandles = new WaitHandle[10]; for (int i = 0; i < 10; i++
var connectionInfo = new WSManConnectionInfo();
var runspacePool = RunspaceFactory.CreateRunspacePool(1, 10, connectionInfo);
runspacePool.Open();
var waitHandles = new WaitHandle[10];
for (int i = 0; i < 10; i++)
{
var powerShell = PowerShell.Create();
powerShell.RunspacePool = runspacePool;
powerShell.AddCommand("Some-long-running-command");
var asyncResult = powerShell.BeginInvoke();
waitHandles[i] = asyncResult.AsyncWaitHandle;
}
WaitHandle.WaitAll(waitHandles);
runspacePool.Close();
执行此代码时,将在目标计算机上创建多少进程和线程?
如何在一个进程/连接中在目标计算机上创建多个线程