2

我正在尝试使用 powershell System.Management.Automationdll 访问远程系统服务详细信息。

当我执行以下代码以连接到远程系统时,我遇到了错误:

代码片段:

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

错误详情:

WinRM 客户端向 HTTP 服务器发送了一个请求,并得到一个响应,指出请求的 HTTP URL 不可用。这通常由不支持 WS-Management 协议的 HTTP 服务器返回

4

1 回答 1

0

我有同样的问题,我使用和工作的 uri 是http://machinename/powershell / 我也有类似的基本身份验证错误消息,所以在某些情况下需要使用 Kerberos。

于 2016-10-18T14:18:39.077 回答