'System.Management.Automation.Remo ting.PSRemotingTransportException' occurred in System.Management.Automation.dll

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?

May 21st, 2015 4:42am

Hi Chandrapalsingh,

Based on my research, powershell remoting shouldn't be affected by powershell version. Because you got the error "access is denied", please make sure the user launching powershell on server 2008r2 has the enough permission to manage the remote server 2012.

To troubleshoot this error, you can also refer to this document:

https://technet.microsoft.com/en-us/library/hh847850.aspx

You can also try to use powershell remoting by the cmdlets below in powershell:

$s = New-PSSession -ComputerName Remoteserver2012
Invoke-Command -Session $s -ScriptBlock { get-process}

If there is anything else regarding this issue, please feel free to post back.

Best Regards,

Anna Wang

Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2015 5:55am

Hi Anna,

Thank for quick reply.

Both machines are in same domain and using same user(domain administrator). So I don't think there is problem with permissions as Code is running if I update the powershell of server 2008r2.

I tried  below commands and It is working. I am able to get the process of remote machine.

$s = New-PSSession -ComputerName Remoteserver2012
Invoke-Command -Session $s -ScriptBlock { get-process}

But somehow this is not working with C# implementation of application.

Is there any problem in the steps I am doing to open the runspace on remote machine?

May 22nd, 2015 8:28am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics