如何从资源管理器PSSession VM?

时间:2016-04-05 08:53:43

标签: powershell azure azure-resource-manager azure-automation runbook

我在资源管理器中有虚拟机,我想从Runbook这些虚拟机执行远程PowerShell脚本编写。我已经知道如何在经典虚拟机中执行此操作并成功使用。

现在,远程PowerShell是否通过SSL在Azure资源管理器创建的Azure VM上默认启用了证书?如何连接Enter-PSSession或Invoke-Command?

我尝试了这段代码但没有成功。

Enter-PSSession -ComputerName <public-IP> -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)

我收到了这个错误

Enter-PSSession : Connecting to remote server <public-IP> 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.

注意:我在Azure自动化中运行Powershell Runbook。 并尝试了建议的答案here

1 个答案:

答案 0 :(得分:1)

您需要在Azure Key Vault中添加证书(以及其他一些步骤)以启用WinRM到ARM VM。然后,您需要执行与Connect-AzureVM Runbook中相同的操作,但使用此证书而不是Azure Classic VM的证书,以在主机之间建立信任。

有关所需步骤的详细信息,请参阅this threadThis也可能有用。