New-PSSession 远程失败,在本地工作
New-PSSession fails remotely, works locally
远程 PC:Windows10 个客户端
我的电脑:Windows 10 个客户端
在远程 PC 上:
- 我可以通过 运行 PowerShell 以管理员身份打开 PSSession 并使用命令
New-PSSession -EnableNetworkAccess
- 如果我不添加 -EnableNetworkAccess 参数,它不起作用,总是给出“访问被拒绝”错误
当我尝试从我的 PC 连接到远程 PC 时,我总是收到“New-PSSession:[localhost] 连接到远程服务器 localhost 失败,并显示以下错误消息:访问是
被拒绝。”错误。
- 远程 PC 在 trustedHosts 列表中(作为名称和 IP)
- 我的 PC 在远程 PC 的 trustedHosts 列表中(作为名称和 IP)
- 我 PC 上的当前用户与远程 PC 上的管理员相同,我通过它在远程 PC 上本地成功访问了新会话
- 运行 在两台 PC 上启用-PS远程
- 完全关闭两台 PC 上的防火墙
- 尝试了运行以下逗号(来自提升和非提升PS):
New-PSSession -RemoteComputer <remoteComputerName>
New-PSSession -RemoteComputer <remoteComputerName> -EnableNetworkAccess
New-PSSession -RemoteComputer <remoteComputerIP>
New-PSSession -RemoteComputer <remoteComputerIP> -EnableNetworkAccess
$cred=Get-Credential
New-PSSession -RemoteComputer <remoteComputerIP> -EnableNetworkAccess -Credential $cred
- winrs 在相同的两台 PC 之间运行良好,例如:
winrs -r:<IP> -u:<userName> -p:<password> cmd.exe
- 阅读以下链接上的所有文档:
https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-7.2
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_requirements?view=powershell-7.2
https://docs.microsoft.com/en-
但也许我在这里遗漏了一些非常基本的东西。远程 PC 是否需要成为 Windows 服务器?
解决了我的问题。
On all systems to which I want to remote-in (remote and localhost) the
following command needs to be executed:
Set-ItemProperty -Name LocalAccountTokenFilterPolicy -Value 1 -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
远程 PC:Windows10 个客户端 我的电脑:Windows 10 个客户端
在远程 PC 上:
- 我可以通过 运行 PowerShell 以管理员身份打开 PSSession 并使用命令
New-PSSession -EnableNetworkAccess
- 如果我不添加 -EnableNetworkAccess 参数,它不起作用,总是给出“访问被拒绝”错误
当我尝试从我的 PC 连接到远程 PC 时,我总是收到“New-PSSession:[localhost] 连接到远程服务器 localhost 失败,并显示以下错误消息:访问是 被拒绝。”错误。
- 远程 PC 在 trustedHosts 列表中(作为名称和 IP)
- 我的 PC 在远程 PC 的 trustedHosts 列表中(作为名称和 IP)
- 我 PC 上的当前用户与远程 PC 上的管理员相同,我通过它在远程 PC 上本地成功访问了新会话
- 运行 在两台 PC 上启用-PS远程
- 完全关闭两台 PC 上的防火墙
- 尝试了运行以下逗号(来自提升和非提升PS):
New-PSSession -RemoteComputer <remoteComputerName>
New-PSSession -RemoteComputer <remoteComputerName> -EnableNetworkAccess
New-PSSession -RemoteComputer <remoteComputerIP>
New-PSSession -RemoteComputer <remoteComputerIP> -EnableNetworkAccess
$cred=Get-Credential
New-PSSession -RemoteComputer <remoteComputerIP> -EnableNetworkAccess -Credential $cred
- winrs 在相同的两台 PC 之间运行良好,例如:
winrs -r:<IP> -u:<userName> -p:<password> cmd.exe
- 阅读以下链接上的所有文档:
https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/running-remote-commands?view=powershell-7.2 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_requirements?view=powershell-7.2 https://docs.microsoft.com/en-
但也许我在这里遗漏了一些非常基本的东西。远程 PC 是否需要成为 Windows 服务器?
On all systems to which I want to remote-in (remote and localhost) the following command needs to be executed:
Set-ItemProperty -Name LocalAccountTokenFilterPolicy -Value 1 -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System