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?
As far as I can read in Microsoft documention Set-AdServerSettings
is not part of ActiveDirectory
module but is an Exchange CmdLet.
Using Exchange Management Shell Commands With Managed Code article show the code you have to write to use Set-AdServerSettings
CmdLet in C#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With