2

我无法使用 powershell 连接到远程机器。我做的程序是:

  1. 启用-PSRemoting -Force
  2. 设置项 WSMan:\localhost\Client\TrustedHosts *
  3. 重启服务winrm
  4. 输入-PSSession IpAddress

当我从我的服务器机器运行最后一步(第 4 步)时,出现如下错误:

Enter-PSSession:连接到远程服务器失败,并显示以下错误消息:访问被拒绝。

我已经在客户端和服务器机器上尝试了上述所有 4 个步骤。请帮忙

谢谢普拉夫

4

1 回答 1

3

检查远程机器上的端口

PS Z:> cd WSMan:\localhost\Listener
PS WSMan:\localhost\Listener> dir
[cut]
PS WSMan:\localhost\Listener> cd .\Listener_1084132640
PS WSMan:\localhost\Listener\Listener_1084132640> dir
WSManConfig:
Microsoft。 WSMan.Management\WSMan::localhost\Listener\Listener_1084132640
名称值
---- -----
地址 *
传输 HTTP
端口 5985

然后连接正确的端口

$remotePowerShellPort = 5985 $ConnectionURI = ("http://{0}:{1}" -f $targetServer, $remotePowerShellPort)
$remoteSession = New-PSSession -ConnectionURI $ConnectionURI
Invoke-Command -Session $remoteSession -ScriptBlock { dir删除-PSSession
$remoteSession

于 2011-03-31T09:37:45.833 回答