【发布时间】:2014-01-25 13:30:19
【问题描述】:
我正在尝试实现一个远程运行空间,它既需要 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 行,我不会收到错误消息,但是由于无法识别到 ViewEntireForest 的 PowerShell 命令 SetADServerSettings,因此无法运行。
堆栈跟踪:
无法执行操作,因为未实现操作“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:line 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:line 151
这些附加信息有帮助吗?有关如何解决此问题的任何想法?
【问题讨论】:
-
您介意为该错误添加堆栈跟踪吗?它可能会提供一些见解。
-
第 122 行(参见堆栈跟踪)是
ImportPSModule()行。 -
欢迎来到 SO,Rob。 +1 对您的问题,以显示良好的努力。不过,您之前的评论确实应该编辑到问题中,因为它可能会帮助其他人帮助您,并且您不希望它隐藏在 cmets 中。
-
可能是您的 ActiveDirectory 模块出错,或者是自动生成的方法自动实现了 NotImplementedException。检查此线程:stackoverflow.com/questions/13929292/…
-
是的,我认为您是对的,我将让我的 Windows 管理员帮我检查一下。在 MD shell 中,我输入了 powershell 以进入 powershell 命令 shell。在 shell 中,我输入命令:
import-module ActiveDirectory,它运行良好,然后是Set-AdServerSettings -ViewEntireForest $True。返回的响应基本上是它没有将其识别为 cmdlet、脚本或可执行程序的名称。这是错误的,因为该 cmdlet 在 ActiveDirectory 模块中。
标签: c# powershell exchange-server runspace