![PowerShell Linux 上缺少 WSMan 提供程序(用于使用远程处理)](https://linux22.com/image/708589/PowerShell%20Linux%20%E4%B8%8A%E7%BC%BA%E5%B0%91%20WSMan%20%E6%8F%90%E4%BE%9B%E7%A8%8B%E5%BA%8F%EF%BC%88%E7%94%A8%E4%BA%8E%E4%BD%BF%E7%94%A8%E8%BF%9C%E7%A8%8B%E5%A4%84%E7%90%86%EF%BC%89.png)
我正在尝试将 PowerShell 从 Linux 远程传输到 Azure 上的 Windows Nano Server。
说明中有一部分我将远程服务器的 IP 添加到本地计算机的受信任主机:
PS > Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value "1.2.3.4"
Set-Item : Cannot find drive. A drive with the name 'WSMan' does not exist.
At line:1 char:1
+ Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value "1.2.3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (WSMan:String) [Set-Item], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetItemCommand
如果我忽略此消息并尝试连接,则会收到错误:
PS > Enter-PSSession -ComputerName "1.2.3.4" -Credential joe -Authentication Basic -Verbose -Port 5985
Windows PowerShell credential request
Enter your credentials.
Password for user joe: **************
Enter-PSSession : Connecting to remote server 1.2.3.4 failed with the following error message : Authentication Failure For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ComputerName "1.2.3.4" -Credential joe -Aut ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (1.2.3.4:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
关于添加 WSMan 提供程序,我所看到的只是我需要运行Enable-PSRemoting
,它在我的 Linux PowerShell 上不存在,而且似乎是为远程计算机设计的(并且 Nano Server 默认启用了它)。