我试图从Linux远程PowerShell到Azure上的Windows Nano服务器。
在说明中,我将远程服务器的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默认启用了它) 。