Create a Windows virtual machine with you workstations PowerShell

Step 1

If you are running PowerShell locally, you also need to run 

Login-AzureRmAccount

 to create a connection with Azure. (note the Ids after login)

Create resource group

Create an Azure resource group with New-AzureRmResourceGroup. A resource group is a logical container into which Azure resources are deployed and managed.

Azure PowerShell

<span class="hljs-pscommand">New-AzureRmResourceGroup</span><span class="hljs-parameter"> -Name</span> myResourceGroup<span class="hljs-parameter"> -Location</span> EastUS

Resource group

portal

Create virtual machine

Create the virtual machine with New-AzureRmVM. You just need to provide names for each of the resources and the New-AzureRMVM cmdlet will create them for you if they don’t already exist.

When running this step, you are prompted for credentials. The values that you enter are configured as the user name and password for the virtual machine.

Azure PowerShell

<span class="hljs-pscommand">New-AzureRmVm</span> `
   <span class="hljs-parameter"> -ResourceGroupName</span> <span class="hljs-string">"myResourceGroup"</span> `
   <span class="hljs-parameter"> -Name</span> <span class="hljs-string">"myVM"</span> `
   <span class="hljs-parameter"> -Location</span> <span class="hljs-string">"East US"</span> `
   <span class="hljs-parameter"> -VirtualNetworkName</span> <span class="hljs-string">"myVnet"</span> `
   <span class="hljs-parameter"> -SubnetName</span> <span class="hljs-string">"mySubnet"</span> `
   <span class="hljs-parameter"> -SecurityGroupName</span> <span class="hljs-string">"myNetworkSecurityGroup"</span> `
   <span class="hljs-parameter"> -PublicIpAddressName</span> <span class="hljs-string">"myPublicIpAddress"</span> `
   <span class="hljs-parameter"> -OpenPorts</span> <span class="hljs-number">80</span>,<span class="hljs-number">3389</span>
login
New Server login credentials

Connect to virtual machine

 

After the deployment has completed, create a remote desktop connection with the virtual machine.

Use the Get-AzureRmPublicIpAddress command to return the public IP address of the virtual machine. Take note of this IP Address so you can connect to it with your browser to test web connectivity in a future step.

Azure PowerShell

<span class="hljs-pscommand">Get-AzureRmPublicIpAddress</span><span class="hljs-parameter"> -ResourceGroupName</span> myResourceGroup | Select IpAddress

Use the following command, on your local machine, to create a remote desktop session with the virtual machine. Replace the IP address with the publicIPAddress of your virtual machine. When prompted, enter the credentials used when creating the virtual machine.


mstsc /v:

You May Also Like

About the Author: Phil

Leave a Reply

Your email address will not be published. Required fields are marked *