远程连接问题

时间:2015-10-26 05:18:18

标签: c# powershell remote-access powershell-remoting

以下是我尝试连接的方式

string shellUri = "http://schemas.microsoft.com/powershell/Microsoft.PowerShell";
string password = "*****";
System.Security.SecureString securePW = new System.Security.SecureString();
foreach (char c in password)
     securePW.AppendChar(c);
securePW.MakeReadOnly();
string domainAndUsername = @"192.168.1.113\[machine-name]\[username]";
string remoteMachineName = "*****";
PSCredential remoteCredential = new PSCredential(domainAndUsername, securePW);
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, remoteMachineName, 5985, "/wsman", shellUri, remoteCredential);
 using (Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo))
 {
   runspace.Open(); //__Error Here__// 
  

PSRemotingTransportException

     

连接到远程服务器失败,并显示以下错误消息:
  访问被拒绝。有关详细信息,请参阅about_Remote_Troubleshooting帮助主题。

我在网上找不到任何东西。甚至告诉我,我是否正确配置了connectionInfo IP,用户名和PC名称等?

0 个答案:

没有答案