Azure User Group Nepal

Learn and understand the cloud technology using Microsoft Azure platform to adopt it

Managing Azure VM using Azure PowerShell

Author: Sakaldeep

July 22, 2017

PowerShell is a faster and more controlled tool to manage Azure VM than logging into the portal. In this post, we will look for a few commands to manage Azure VM. To run the Azure PowerShell command, first, we need to install AzureRM module. If you want to install Azure PowerShell, see Managing Azure Subscription using Azure PowerShell.

Before trigger azure PowerShell command, login to an azure subscription using command Login-AzreRMAccount. To create VM, see Provision VM using Azure PowerShell.

To list out all the VMs available in the subscription.

Command: Get-AzureRmVM

To list out VMs from specific resource group

Command: Get-AzureRmVM -ResourceGroupName prod-vm 

To know the public IP address of VM.

Command:  Get-AzureRmPublicIpAddress -ResourceGroupName prod-vm 

Connect to Azure VM

Command: mstsc /v:<public ip> 

To know the state of VM

Command: Get-AzureRmVM -ResourceGroupName prod-vm -Name win-vm1 -Status 

Stop VM

Command: Stop-AzureRmVM -ResourceGroupName prod-vm -Name win-vm1 -Force 

Start VM

Command: Start-AzureRmVM -ResourceGroupName prod-vm -Name win-vm1 

Hope this post is helpful to you.

Total visits : 42