Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Powershell Runbook-在远程VM上调用命令(ARM a.k.a.V2)_Powershell_Azure_Remote Management - Fatal编程技术网

Azure Powershell Runbook-在远程VM上调用命令(ARM a.k.a.V2)

Azure Powershell Runbook-在远程VM上调用命令(ARM a.k.a.V2),powershell,azure,remote-management,Powershell,Azure,Remote Management,我需要什么 我想要一个在远程VM(VM是V2或“资源管理器”VM)上执行命令的自动化runbook 我找到了一些例子,可以让它在经典虚拟机上工作,但我不能让它在RM虚拟机上工作(我发现最好的:) 是否有人在自动化runbook中的远程V2虚拟机上运行powershell命令的示例 我目前被困的地方 我试图调整示例代码的第二部分(调用命令的部分),但出现以下错误: [vm-template] Connecting to remote server vm-template failed with t

我需要什么

我想要一个在远程VM(VM是V2或“资源管理器”VM)上执行命令的自动化runbook

我找到了一些例子,可以让它在经典虚拟机上工作,但我不能让它在RM虚拟机上工作(我发现最好的:)

是否有人在自动化runbook中的远程V2虚拟机上运行powershell命令的示例

我目前被困的地方

我试图调整示例代码的第二部分(调用命令的部分),但出现以下错误:

[vm-template] Connecting to remote server vm-template 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.
+ CategoryInfo          : OpenError: (vm-template:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : ServerNotTrusted,PSSessionStateBroken
我的理解是,因为我没有使用Kerberos(甚至不知道它是什么),所以我必须使用HTTPS。为此,我必须完成示例代码的前半部分,这是关于导入证书的(顺便说一句,导入自runbook在azure中运行以来的位置)

我发现一些页面解释了如何启用HTTPS()和创建证书(),但它们需要在两台机器上运行一些命令;我当然可以在我的远程虚拟机上运行命令,但我不明白如何在客户机上运行命令,因为运行手册直接在azure中运行,所以客户机实际上并不存在


非常感谢您的帮助,谢谢

如果使用https,您的网络安全组是否配置为打开端口5985(winrm http端口)或5986?如果您计划使用winrm而不是Azure automation,那么您可能还需要一个公共IP。您还应该能够使用http,因此我认为您看到的错误是一个通用的连接失败错误

注意:默认情况下,应设置winrm over http和侦听器,并在您的计算机上进行侦听。winrm使用消息级加密,所以它不完全是纯文本。您可以通过以下方式进行验证:

winrm e winrm/config/listener

它应该向您的听众展示如下内容:

Listener [Source="GPO"]
    Address = *
    Transport = HTTP
    Port = 5985
    Hostname
    Enabled = true
    URLPrefix = wsman
    CertificateThumbprint
    ListeningOn = 1.1.1.1
一旦您验证了这一点,我将验证您是否可以从自己的计算机使用winrm连接到远程计算机。您可以通过以下方式轻松做到这一点:

$username = '<admin-user>'
$pass = ConvertTo-SecureString -string '<password>' -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $pass
Enter-PSSession -ComputerName <public-IP> -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)
$username=''
$pass=converttosecurestring-string'-AsPlainText-Force
$cred=新对象-typename System.Management.Automation.PSCredential-argumentlist$username,$pass
输入PSSession-ComputerName-Credential$cred-SessionOption(新的PSSessionOption-SkipCACheck-SkipCheck-SkipLocationCheck)
请注意,您可能必须将自己计算机上的受信任主机设置为信任Azure计算机以创建winrm会话。这可以通过以下方法实现:
设置项目WSMan:localhost\Client\TrustedHosts-value*-Force


请注意,为了安全起见,您应该使用Azure VM的实际名称,而不是通配符。

谢谢-运行该命令向我表明问题出在
ListeningOn=null
上。我转到组策略
允许通过WinRM进行远程服务器管理
,并将“*”作为IP筛选器,从而修复了它。起初我有我的客户机的IP地址,但我想我误解了设置。因此,我现在假设要确保这一点,并确保只有我的客户端计算机可以允许WinRM,因为它依赖azure中的安全组防火墙。我将接受从客户机而不是runbook运行命令——我发现它在运行之前在他们的队列中停留的时间太长了。谢谢您知道发送到远程机器的命令有多安全吗?我知道它在使用HTTP,但你是说消息是加密的?我可以使用此设置发送包含凭据和敏感值的生产命令吗?或者我现在应该使用HTTPS而不是HTTP吗?您好,您是否使用runbook在ARM VM中成功运行了该命令?你做了什么?我也有同样的问题和错误,但找不到任何对我有帮助的文章。很抱歉,我放弃了Runbook并使用自己的服务器发出命令。