问题
I am trying to access the Remote system service details using powershell System.Management.Automation
dll.
When i am executing the below code to connect to the remote system I am facing the error:
Code snippet:
string shellUri = "http://schemas.microsoft.com/powershell/Microsoft.PowerShell";
PSCredential remoteCredential = new PSCredential("uname", this.convertToSecureString("password"));
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("http://machinename/powershell"), shellUri, remoteCredential);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);
runspace.Open();//Here Exception raised
Error Details:
The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is usually returned by a HTTP server that does not support the WS-Management protocol
回答1:
I had the same issue, the uri that i used and worked is http://machinename/powershell/ I had also similar error message with basic authentification, so using Kerberos is needed in some cases.
来源:https://stackoverflow.com/questions/27798696/winrm-client-sent-a-request-to-an-http-server-while-opening-runspace-in-winrm