PowerShell 访问被拒绝。PSRemotingTransportException +fullyQualifiedErrorId : PSSessionStateBroken

Ajm*_*een 7 powershell remote-desktop access-denied powershell-remoting

我试图建立到另一个系统的远程连接并执行一些基本命令。

以下是我所做的步骤:

  • 配置远程机器以接受 Shell 命令 - Enable-PSRemoting - Force
  • 在远程机器上测试了配置 - Test-WsMan COMPUTERNAME。
  • 在主机上执行以下命令:

1. Invoke-Command -ComputerName COMPUTERNAME -ScriptBlock { Get-ChildItem C:\ } -credential USERNAME.

2. Invoke-Command -ComputerName COMPUTERNAME -ScriptBlock { Get-ChildItem C:\ } -credential $Credentials.

3.Invoke-Command -ComputerName COMPUTERNAME -ScriptBlock { Get-ChildItem C:\ }

在所有情况下,我们都收到拒绝访问错误:

Access is denied. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo   : OpenError: (:) [], PSRemotingTransportException 
+ FullyQualifiedErrorId : PSSessionStateBroken
Run Code Online (Sandbox Code Playgroud)

Moe*_*ald 5

MSDN

  1. 通过右键单击 Windows PowerShell 快捷方式并选择以管理员身份运行,以管理员身份启动 Windows PowerShell。

  2. WinRM 服务默认配置为手动启动。您必须将启动类型更改为自动,并在要使用的每台计算机上启动该服务。在 PowerShell 提示符下,您可以使用以下命令验证 WinRM 服务是否正在运行: get-service winrm 输出中状态属性的值应为“正在运行”。

  3. 要配置 Windows PowerShell 进行远程处理,请键入以下命令:Enable-PSRemoting –force

在许多情况下,您将能够使用其他域中的远程计算机。但是,如果远程计算机不在受信任域中,则远程计算机可能无法验证您的凭据。要启用身份验证,您需要将远程计算机添加到 WinRM 中本地计算机的受信任主机列表中。为此,请键入: winrm s winrm/config/client '@{TrustedHosts="RemoteComputer"}' 这里,RemoteComputer 应该是远程计算机的名称,例如:winrm s winrm/config/client '@{TrustedHosts= “CorpServer56”}'

你应该检查是否 winrm正在运行。还将您的远程主机添加到受信任的主机列表(或您的本地机器)。

希望有帮助。

  • 我能够解决这个问题。看起来我必须修改远程计算机中 Windows PowerShell 远程处理的安全配置。我使用命令 Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell 在远程计算机上添加客户端用户。然后我就能够从客户端机器到远程机器进行通信, (3认同)