- 配置远程计算机以接受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