I'm trying to implement a remote runspace that needs both connectionInfo to talk to Exchange and an imported module to talk to active directory. Here is problem code:
runspace = System.Management.Automation.Runspaces.RunspaceFactory.
CreateRunspace(psConnectionInfo);
runspace.InitialSessionState.ImportPSModule(new[] { "ActiveDirectory" });
runspace.Open();
The runtime error I get is:
Cannot perform operation because operation "NewNotImplementedException at offset 32 in file:line:column :0:0" is not implemented
If I omit the runspaceInitialSessionState
line I don't get the error but the PowerShell command SetADServerSettings
to ViewEntireForest fails to run because it's not recognized.
StackTrace:
Cannot perform operation because operation "NewNotImplementedException at offset 32 in file:line:column :0:0 " is not implemented. at System.Management.Automation.RemoteRunspace.get_InitialSessionState() at ManageUserForwardsWS.ManageUserForwards.SetExchangeCredentials(String userName, String PwString) in c:\Users\rtanner.CATNET\Documents\Visual Studio 2013\Projects\ManageUserForwardsWS\ManageUserForwardsWS\ManageUserForwards.asmx.cs:line 122
I can also generate the same error with this code instead:
Pipeline pipeline = runspace.CreatePipeline();
PowerShell powershell = PowerShell.Create();
powershell.Runspace = pipeline.Runspace;
powershell.Runspace.InitialSessionState.ImportPSModule(new[] { "ActiveDirectory" });
And here's the StackTrace:
Cannot perform operation because operation "NewNotImplementedException at offset 32 in file:line:column :0:0" is not implemented. at System.Management.Automation.RemoteRunspace.get_InitialSessionState() at ManageUserForwardsWS.ManageUserForwards.SetForward(String sAMAccountName, String fowardAddress) in c:\Users\rtanner.CATNET\Documents\Visual Studio 2013\Projects\ManageUserForwardsWS\ManageUserForwardsWS\ManageUserForwards.asmx.cs:line 151
Does this added information help? Any ideas on how to fix this?
ImportPSModule()
line. – Choseimport-module ActiveDirectory
and that worked fine and thenSet-AdServerSettings -ViewEntireForest $True
. the response that came back was basically that it didn't recognize it as the name of a cmdlet, script, or executable program. And that is wrong since that cmdlet is in the ActiveDirectory module. – Chose