我正在尝试实现一个远程运行空间,它既需要 connectionInfo 与 Exchange 通信,又需要一个导入的模块来与 Active Directory 通信。这是问题代码:
runspace = System.Management.Automation.Runspaces.RunspaceFactory.
CreateRunspace(psConnectionInfo);
runspace.InitialSessionState.ImportPSModule(new[] { "ActiveDirectory" });
runspace.Open();
我得到的运行时错误是:
无法执行操作,因为操作“NewNotImplementedException at offset 32 in file:line:column:0:0”未实现
如果我省略该runspaceInitialSessionState
行,我不会收到错误消息,但是SetADServerSettings
ViewEntireForest 的 PowerShell 命令无法运行,因为它无法识别。
堆栈跟踪:
无法执行操作,因为未实现操作“NewNotImplementedException at offset 32 in file:line:column :0:0”。在 System.Management.Automation.RemoteRunspace.get_InitialSessionState() 在 ManageUserForwardsWS.ManageUserForwards.SetExchangeCredentials(String userName, String PwString) 在 c:\Users\rtanner.CATNET\Documents\Visual Studio 2013\Projects\ManageUserForwardsWS\ManageUserForwardsWS\ManageUserForwards.asmx .cs:第 122 行
我也可以使用此代码生成相同的错误:
Pipeline pipeline = runspace.CreatePipeline();
PowerShell powershell = PowerShell.Create();
powershell.Runspace = pipeline.Runspace;
powershell.Runspace.InitialSessionState.ImportPSModule(new[] { "ActiveDirectory" });
这是 StackTrace:
无法执行操作,因为操作“NewNotImplementedException at offset 32 in file:line:column:0:0”未实现。在 System.Management.Automation.RemoteRunspace.get_InitialSessionState() 在 ManageUserForwardsWS.ManageUserForwards.SetForward(String sAMAccountName, String fowardAddress) 在 c:\Users\rtanner.CATNET\Documents\Visual Studio 2013\Projects\ManageUserForwardsWS\ManageUserForwardsWS\ManageUserForwards.asmx .cs:第 151 行
这些附加信息有帮助吗?有想法该怎么解决这个吗?