I am using below code for opening a runspace on server machine.
using (this.impersonator.CreateContext()) // using for impersonation
{
string remoteManagementPort = this.TryGetRemotePowershellPort("ServerName");// port is coming fine from server
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(http://"ServerName":"PortNumber"/wsman);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
connectionInfo.OperationTimeout = 2 * 60 * 1000; // 2 minutes.
connectionInfo.OpenTimeout = 1 * 60 * 1000; // 1 minute.
this.runSpace= RunspaceFactory.CreateRunspace(connectionInfo); // working fine. Able to create Runspace
this.runSpace.ApartmentState = Threading.ApartmentState.STA;
this.runSpace.ThreadOptions = PSThreadOptions.UseCurrentThread;
this.runSpace.Open(); // Here I am getting this Exception.
this.IsInitialized = true;
}
}
Exception:
An unhandled exception of type 'System.Management.Automation.Remoting.PSRemotingTransportException' occurred in System.Management.Automation.dll
Additional information: Processing data from remote server failed with the following error message: Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
Note: I am getting this exception when My web application sits at windows 2k8 R2 (Powershell Version 2.0) and Remote Server is on windows 2012 server (powershell Version 3.0).
It is working if I update the powershell version 2.0 to version 3.0 on client machine.
I didn't get anything saying that there is an issue with v2.0 to v3.0 connections.
Can someone please give me any guidance why it is not working with v2 and v3?