远程PowerShell来AzureRM虚拟机 [英] Remote PowerShell to AzureRM Virtual Machines

查看:167
本文介绍了远程PowerShell来AzureRM虚拟机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地部署了一些Azure的虚拟机到Azure的资源组。也就是说,我用新的<一个href=\"https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-deploy-rmtemplates-powershell/\"相对=nofollow>天青资源管理器部署模型从一个JSON模板部署的虚拟机和相关资源。

I have successfully deployed a number of Azure virtual machines to an Azure Resource Group. That is, I'm using the new Azure Resource Manager deployment model to deploy the virtual machines and the related resources from a JSON template.

我的问题是如何从对这些虚拟机我的笔记本电脑进行远程PowerShell脚本。我经历了许多文章都谈妥了 - 但他们都表现出了如何在Azure中的经典虚拟机做。这个我已经知道并成功使用。

My problem is how to do remote PowerShell scripting from my laptop computer against these VMs. I have combed through many articles already - but they all show how to do it with the classic virtual machines in Azure. This I already know and use with success.

现在,是远程PowerShell通过SSL与Azure的资源管理器中创建默认情况下,在Azure上的虚拟机启用了证书?我怎样进入-的PSSession或调用命令连接?

Now, is remote PowerShell over SSL with a certificate enabled by default on Azure VMs created with the Azure Resource Manager? How do I connect with Enter-PSSession or Invoke-Command ?

推荐答案

这是对现有机器:确保您的虚拟机有通过NIC设置一个公网IP。接下来,请确保您的防火墙是对公共交通开放,如果你要使用你的笔记本电脑。这可以用一个简单的netsh命令进行:

This is for an existing machine: make sure that your VM has a public IP through the NIC settings. Next, make sure that your firewall is open to public traffic if you're going to use your laptop. This can be done with a simple netsh command:

netsh advfirewall firewall add rule name="WinRM HTTP" dir=in action=allow protocol=TCP localport=5985 profile=public

一旦你有一个公网IP和防火墙上打开你可以输入一个Wi​​nRM的会话:

Once you have a public IP and firewall open you can enter a WinRM session with:

$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)

请注意:默认情况下,WinRM的通过HTTP和听者应设立并监听你的机器。 HTTPS未启用,因为目前还不清楚从哪里拿到证书。但是,WinRM的使用消息级别的加密,所以它不是完全明文。您可以验证:

Note: by default, WinRM over HTTP and the listener should be set up and listening on your machines. HTTPS is not enabled since it's not clear where to get the certificate. However, WinRM uses message level encryption, so it's not completely in plaintext. You can verify with:

winrm e winrm/config/listener

这应该告诉你的东西,如监听器:

Which should show you the listener with something like:

Listener [Source="GPO"]
    Address = *
    Transport = HTTP
    Port = 5985
    Hostname
    Enabled = true
    URLPrefix = wsman
    CertificateThumbprint
    ListeningOn = 1.1.1.1

这篇关于远程PowerShell来AzureRM虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆