【问题标题】:How to PSSession VM from Resource Manager?如何从资源管理器 PSSession VM?
【发布时间】:2016-07-25 02:36:05
【问题描述】:

我在资源管理器中有虚拟机,我想从这些虚拟机的运行手册中执行远程 PowerShell 脚本。我已经知道如何在经典虚拟机中做到这一点并成功使用。

现在,是否在使用 Azure 资源管理器创建的 Azure VM 上默认启用了证书的远程 PowerShell over SSL?如何连接 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

【问题讨论】:

  • 使用 HTTPS 配置您的 VM 远程 PowerShell,然后重试。你应该有Transport = HTTPSPort = 5986
  • @JackZeng 已经这样做了 ='( 但远程处理仍然没有成功

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


【解决方案1】:

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

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

【讨论】:

  • 我仍然无法连接 ='( 我也按照这里的步骤进行操作 -> blogs.technet.microsoft.com/uktechnet/2016/02/11/…
  • 我尝试在本地计算机中使用 Powershell 进入 PSSession,它工作正常,我只是将远程服务器的 public_ip 放到了trustedhost。那么现在,我将如何在 azure 门户中执行此操作?你有什么想法吗?
  • 我认为 Enter-PSSession 不能用于 Azure 自动化运行的无人参与会话。一旦代码进入会话,就没有用户在场来指定下一个要运行的命令。 Invoke-Command 呢?
  • 此外,从 PowerShell 信任主机的方法是将其证书添加到受信任的存储区,这就是 Connect-AzureVM 运行手册的用途,除非您需要使用 VM 的证书在Azure Key Vault,因为这是 ARM VM 而不是经典 VM。
  • 如果您可以绕过 VM 证书的信任验证,可以使用 New-PSSessionOption -SkipCACheck 绕过,并通过 -SessionOption 参数将该 PSSessionOption 传递给 Invoke-Command。有关详细信息,请参阅technet.microsoft.com/en-us/library/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-05
  • 1970-01-01
  • 1970-01-01
  • 2015-09-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多