C# 从c Management.Automation.Runspaces远程启动Powershell脚本
我正在尝试远程执行传入对象参数的powershell脚本。我已经成功地做到了这一点,但现在我只想启动脚本,断开远程会话,并让powershell脚本继续在远程计算机上执行。不幸的是,我一直无法做到这一点 这是我到目前为止的代码,它成功地运行了远程powershell脚本,但如果我处置了会话,powershell脚本也会停止执行:C# 从c Management.Automation.Runspaces远程启动Powershell脚本,c#,powershell,winrm,C#,Powershell,Winrm,我正在尝试远程执行传入对象参数的powershell脚本。我已经成功地做到了这一点,但现在我只想启动脚本,断开远程会话,并让powershell脚本继续在远程计算机上执行。不幸的是,我一直无法做到这一点 这是我到目前为止的代码,它成功地运行了远程powershell脚本,但如果我处置了会话,powershell脚本也会停止执行: PowerShell ps = PowerShell.Create(); ps.Runspace = _runspace; ps.AddCommand(scriptPa
PowerShell ps = PowerShell.Create();
ps.Runspace = _runspace;
ps.AddCommand(scriptPath);
if (scriptParameters != null)
{
foreach (var parameter in scriptParameters)
{
ps.AddParameter(parameter.Key, parameter.Value);
}
}
ps.Invoke();
即使在断开远程会话连接的情况下,如何启动.ps1脚本并保持其运行?您只能使用Powershell 3+执行此操作。我还没有测试它,但我认为连接的双方都需要支持断开连接的会话 在.Net中,您将使用 与Powershell等效的是