【发布时间】:2020-02-19 18:55:26
【问题描述】:
我正在尝试将 zip 文件发送并解压缩到 azure VM,但无法连接到远程 Azure VM。
代码
$cred = Get-Credential
$SO = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$session = New-PSSession -ConnectionUri 'http://xx.xx.xxx.xxx:3389' -Credential $cred -SessionOption $SO
Send-File -Path C:\testArchive.zip -Destination C:\ -Session $session
Expand-Archive -Path C:\testArchive.zip -DestinationPath C:\ -Session $session
错误
New-PSSession : [xx.xx.xxx.xxx] Connecting to remote server xx.xx.xxx.xxx
failed with the following error message : The client cannot connect to the
destination specified in the request. Verify that the service on the
destination is running and is accepting requests. Consult the logs and
documentation for the WS-Management service running on the destination, most
commonly IIS or WinRM. If the destination is the WinRM service, run the
following command on the destination to analyze and configure the WinRM
service: "winrm quickconfig". For more information, see the
about_Remote_Troubleshooting Help topic.
At line:4 char:12
+ $session = New-PSSession -ConnectionUri 'http://xx.xx.xxx.xxx:3389' - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:Re
moteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed
以下是我在 azure VM 上运行“winrm quickconfig”命令时的输出
WinRM service is already running on this machine.
WinRM is already set up for remote management on this computer.
当我运行“Enter-PSSession -ComputerName LoadTestVm -Port 3389 -Credential qa-admin”时
Enter-PSSession : Connecting to remote server LoadTestVm failed with the following error
message : The WinRM client cannot process the request because the server name cannot be
resolved. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ComputerName LoadTestVm -Port 3389 -Credential qa-ad ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (LoadTestVm:String) [Enter-PSSession], PSRem
otingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
【问题讨论】:
-
如果您只是执行
Enter-PSSession -ComputerName VMName并在出现提示时输入凭据,是否可行?如果没有,你已经找到了你的问题。如果是,那么您的$cred对象可能有问题。尝试$cred = Get-Credential并手动输入用户名/密码对,然后将该对象提供给您的New-PSSession,看看是否可行。 -
用输出更新了问题。 @马修
标签: powershell virtual-machine rdp winrm azure-vm