0

我正在尝试使用 Azure Runbook 脚本中的 WINRM HTTP 客户端作为工作流模块,在与 Azure Active Directory 域控制器连接的 azure 虚拟机中执行远程命令。这是我连接远程会话的代码。

代码:

    $uri- kerberoscluster.eastus2.cloudapp.azure.com (WINRM HTTP port 5985 and WINRM HTTPS port 5986 were enabled)

    $cred- New-Object -typename System.Management.Automation.PSCredential -argumentlist $vmusername, $vmsecurepassword 

New-PSSession -ComputerName $uri -Credential $cred 

我需要使用 runbook 脚本将远程命令执行到 azure 虚拟机中。但 Runbook 脚本执行已暂停,但出现以下异常。同样的事情在本地网络中运行良好。

The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: [kerberoscluster.eastus2.cloudapp.azure.com] Connecting to remote server kerberoscluster.eastus2.cloudapp.azure.com failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
https://docs.microsoft.com/en-us/azure/automation/automation-troubleshooting-automation-errors#troubleshoot-common-errors-when-working-with-runbooks

我还尝试通过参考以下链接 https://blogs.technet.microsoft.com/rohit-minni/2017/01/18/remoting-into-azure-arm-virtual使用 WINRM HTTPS 客户端连接远程会话-machines-using-powershell/

得到以下异常:

New-PSSession : [kerberoscluster.eastus2.cloudapp.azure.com] Connecting to remote server
kerberoscluster.eastus2.cloudapp.azure.com failed with the following error message : WinRM cannot complete the
operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and
that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM
firewall exception for public profiles limits access to remote computers within the same local subnet. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ New-PSSession -ComputerName $uri -Credential $cred -UseSSL -SessionOption $sessi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
   gTransportException
    + FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionOpenFailed

任何帮助将不胜感激。

4

1 回答 1

0

用于运行 Runbook 的组织用户 ID 或 SPN 是否具有对包含 VM 的资源组的所需权限?此错误通常是由于权限问题引起的。

于 2017-12-11T14:08:08.210 回答