1
votes

Here's the code I'm using:

const string username = "domain\\user";
const string password = "password";
var credentials = new PSCredential(username, password.ToSecureString());
var connInfo = new WSManConnectionInfo(new Uri("https://server.domain.com/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credentials)
                           {AuthenticationMechanism = AuthenticationMechanism.Negotiate};

var rS = RunspaceFactory.CreateRunspace(connInfo);

rS.Open();

Here's the Exception:

Connecting to remote server server.domain.com 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: For more information, see the about_Remote_Troubleshooting Help topic.

So here's my confusion.

  • I checked the WSMan:\localhost\Client on the client computer, and made sure AllowUnencrypted was $true.
  • I checked WSMan:\localhost\Service on the server and made sure AllowUnencrypted was $true.
  • WSMan:\localhost\Service\Auth has Negotiate as well as Kerberos set to $true as well.

What else can I check to get rid of the exception?

1

1 Answers

1
votes

I have no way to test this, but after looking at another example at an MSDN Blog, it seems that you need to update your connInfo line to add the servername, no matter which credentials you choose to use.

var connInfo = new WSManConnectionInfo(new Uri("https://server.domain.com/powershell", ADD_SERVER_NAME_HERE), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credentials) { AuthenticationMechanism = AuthenticationMechanism.Negotiate };