New-PSSession 远程失败,在本地工作

New-PSSession fails remotely, works locally

远程 PC:Windows10 个客户端 我的电脑:Windows 10 个客户端

在远程 PC 上:

New-PSSession -EnableNetworkAccess

当我尝试从我的 PC 连接到远程 PC 时,我总是收到“New-PSSession:[localhost] 连接到远程服务器 localhost 失败,并显示以下错误消息:访问是 被拒绝。”错误。

    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 -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