Exception when opening a Remote Runspace using WSManConnectionInfo

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
I am trying to use WinRM to run commands on a remote machine, but first I am trying on my local machine. I got this code from another forum post ( http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a0e5b23c-b605-431d-a32f-942d7c5fd843 http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/a0e5b23c-b605-431d-a32f-942d7c5fd843 ) but I have been getting errors all along. My fucntion is the following:
<pre lang="x-c# public static void openRunspace(string uri, string schema, string username, string livePass, ref Runspace remoteRunspace)

{

System.Security.SecureString password = new System.Security.SecureString();

foreach (char c in livePass.ToCharArray())

{

password.AppendChar(c);

}

PSCredential psc = new PSCredential(username, password);

WSManConnectionInfo rri = new WSManConnectionInfo(false, "fci-sp-ps", 5985, "/wsman", "http://schemas.microsoft.com/powershell/Microsoft.PowerShell", psc);

rri.AuthenticationMechanism = AuthenticationMechanism.Kerberos;

rri.ProxyAuthentication = AuthenticationMechanism.Negotiate;

remoteRunspace = RunspaceFactory.CreateRunspace(rri);

remoteRunspace.Open();

}

[/code]
I am sending the following parameters:
uri = <span style="font-family:Consolas;color:#a31515;font-size:x-small <span style="font-family:Consolas;color:#a31515;font-size:x-small <span style="font-family:Consolas;color:#a31515;font-size:x-small http://FCI-SP-PS/wsman http://FCI-SP-PS/wsman
schema = <span style="font-family:Consolas;color:#a31515;font-size:x-small <span style="font-family:Consolas;color:#a31515;font-size:x-small <span style="font-family:Consolas;color:#a31515;font-size:x-small http://schemas.microsoft.com/powershell/Microsoft.PowerShell http://schemas.microsoft.com/powershell/Microsoft.PowerShell
<span style="font-family:Consolas;color:#a31515;font-size:x-small <span style="font-family:Consolas;color:#a31515;font-size:x-small <span style="font-family:Consolas;color:#a31515;font-size:x-small username = domain my_username
<span style="font-family:Consolas;color:#a31515;font-size:x-small <span style="font-family:Consolas;color:#a31515;font-size:x-small <span style="font-family:Consolas;color:#a31515;font-size:x-small password = My Password
When the remoteRunspace is opened, I get:
Connecting to remote server failed with the following error message : Logon failure: unknown user name or bad password. For more information, see the about_Remote_Troubleshooting Help topic.
The username and password sent to the function are correct, I am sure about that. If I change the authentication to Basic, I get the following exception instead:
Connecting to remote server failed with the following error message : The WinRM client cannot process the request. The authentication mechanism requested by the client is not supported by the server or unencrypted traffic is disabled in the service configuration. Verify the unencrypted traffic setting in the service configuration or specify one of the authentication mechanisms supported by the server. To use Kerberos, specify the computer name as the remote destination. Also verify that the client computer and the destination computer are joined to a domain. To use Basic, specify the computer name as the remote destination, specify Basic authentication and provide user name and password. Possible authentication mechanisms reported by server: Negotiate Kerberos For more information, see the about_Remote_Troubleshooting Help topic.
Ive done many things to try and fix this, all have failed:

Enabled Unecrypted traffic on the client
Set everyone (*) as a trusted host on the client
Disable Firewalls
Specified

I have also used another constructor for WsManConnectionInfo:
<pre lang="x-c# WSManConnectionInfo rri = new WSManConnectionInfo(new Uri(uri), schema, psc);[/code]
But I get the same results.
Any pointers are greatly appreciated.


View the full article
 
Back
Top