I get a weird exception after solved SSL certificate issue. Please help! My code: PSCredential credential = new PSCredential("domain\administrator", securePwd);
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://www.xxx.com/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
using (runspace)
{
Collection<PSObject> psObject = GetUserInformation(10, runspace);
}
public Collection GetUserInformation(int count, Runspace runspace) { using (PowerShell powershell = PowerShell.Create()) {
powershell.AddCommand("Get-Users");
powershell.AddParameter("ResultSize", count);
runspace.Open();//**error happens**
powershell.Runspace = runspace;
return powershell.Invoke();
}
}
Error message: "Connecting to remote server failed with the following error message : The WinRM client cannot process the request. The WinRM client tried to use Negotiate authentication mechanism, but the destination computer (www.xxx.com:443) returned an 'access denied' error. Change the configuration to allow Negotiate authentication mechanism to be used or specify one of the authentication mechanisms supported by the server. To use Kerberos, specify the local 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 local computer name as the remote destination, specify Basic authentication and provide user name and password."
I use basic authentication, and provide username and credential, why it says "tried to use Negotiate authentication mechanism"?