我正在尝试使用
创建一个Runspace System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(RunspaceConnectionInfo
但我无法弄清楚如何创建 RunspaceConnectionInfo 对象。它是抽象的,我能找到的唯一子类是 WSManConnectionInfo 对象。
我应该创建自己的RunspaceConnectionInfo子类吗?
答案 0 :(得分:0)
CreateRunspace
是一种静态方法。你需要像这样调用它:
PS D:\> $runspace = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
PS D:\> $runspace
Events :
ThreadOptions : Default
JobManager :
RunspaceConfiguration : System.Management.Automation.Runspaces.RunspaceConfigForSingleShell
InitialSessionState :
Version : 3.0
RunspaceStateInfo : BeforeOpen
RunspaceAvailability : None
ConnectionInfo :
OriginalConnectionInfo :
LanguageMode :
ApartmentState : Unknown
InstanceId : 49589d51-38db-4532-9914-0fd7f3306819
SessionStateProxy : System.Management.Automation.Runspaces.SessionStateProxy
Debugger :
PS D:\>
答案 1 :(得分:0)
我正在进行更多挖掘,看起来远程电源shell运行在WSMan上,因此使用WSManConnectionInfo对象可以正常工作!