我无法使用 powershell 连接到远程机器。我做的程序是:
- 启用-PSRemoting -Force
- 设置项 WSMan:\localhost\Client\TrustedHosts *
- 重启服务winrm
- 输入-PSSession IpAddress
当我从我的服务器机器运行最后一步(第 4 步)时,出现如下错误:
Enter-PSSession:连接到远程服务器失败,并显示以下错误消息:访问被拒绝。
我已经在客户端和服务器机器上尝试了上述所有 4 个步骤。请帮忙
谢谢普拉夫
我无法使用 powershell 连接到远程机器。我做的程序是:
当我从我的服务器机器运行最后一步(第 4 步)时,出现如下错误:
Enter-PSSession:连接到远程服务器失败,并显示以下错误消息:访问被拒绝。
我已经在客户端和服务器机器上尝试了上述所有 4 个步骤。请帮忙
谢谢普拉夫
检查远程机器上的端口
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