无法将二进制文件复制到远程 Azure VM



我有一个来自本地(VMWare(的Shavlink代理二进制文件,必须复制到Azure VM。

我使用目标 Azure VM 的公共 VM 来执行复制:

Copy-Item –Path "C:ProgramDataLANDESKShavlik ProtectConsoleDataFilesSTPlatformUpdater.exe" –Destination "D:Shavlik-Agent" –ToSession (New-PSSession –ComputerName a.b.c.d)

不幸的是,它给出了如下错误:

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

在远程计算机上,我启用了端口 5985 和5986,想知道我需要做什么才能使其工作?

您需要将 Winrm 配置为信任远程计算机,最简单的方法是:

Set-Item WSMan:localhostClientTrustedHosts -Value "a.b.c.d"

阅读: https://learn.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management

最新更新