【发布时间】:2014-02-08 05:45:05
【问题描述】:
我根据以下代码创建 PowerShell 远程处理会话:
AuthenticationMechanism auth = AuthenticationMechanism.Negotiate;
WSManConnectionInfo ci = new WSManConnectionInfo(
false,
sRemote,
5985,
@"/wsman",
@"http://schemas.microsoft.com/powershell/Microsoft.PowerShell";,
creds);
ci.AuthenticationMechanism = auth;
Runspace runspace = RunspaceFactory.CreateRunspace(ci);
runspace.Open();
PowerShell psh = PowerShell.Create();
psh.Runspace = runspace;
我有两个问题,基于这段代码sn-p:
- 我需要长时间运行此会话;因此我需要确保远程会话处于活动状态。我该怎么做?
- 我可以更改会话保持活动的持续时间吗?
【问题讨论】:
-
好问题 - 刚刚发布了答案。
标签: c# powershell powershell-remoting