Unable to copy a binary to a remote Azure VM

不想你离开。 提交于 2021-01-29 07:52:06

问题


I have a Shavlink agent binary from on-prem(VMWare) that has to be copied across to a Azure VM(s).

I used the public VM of the target Azure VM to perform the copy:

Copy-Item –Path "C:\ProgramData\LANDESK\Shavlik Protect\Console\DataFiles\STPlatformUpdater.exe" –Destination "D:\Shavlik-Agent\" –ToSession (New-PSSession –ComputerName a.b.c.d)

Unfortunately, it gives error as below:

New-PSSession : [a.b.c.d] Connecting to remote server a.b.c.d. failed with the following error message : The WinRM client cannot process the request. Default
authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit
credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to
set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:143
+ ... avlik-Agent\" –ToSession (New-PSSession –ComputerName a.b.c.d.)
+                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CannotUseIPAddress,PSSessionOpenFailed
Copy-Item : Cannot validate argument on parameter 'ToSession'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again
At line:1 char:142
+ ... avlik-Agent\" –ToSession (New-PSSession –ComputerName a.b.c.d+                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Copy-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.CopyItemCommand

On remote machine, I have enabled ports 5985 and 5986 wondering what I need to do to make it working?


回答1:


you need to configure your winrm to trust the remote machine, easiest way of doing this is the following:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "a.b.c.d"

reading: https://docs.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management



来源:https://stackoverflow.com/questions/57847446/unable-to-copy-a-binary-to-a-remote-azure-vm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!