Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Azure PowerShell Quick Start Guide

You're reading from   Azure PowerShell Quick Start Guide Deploy and manage Azure virtual machines with ease

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher Packt
ISBN-13 9781789614954
Length 118 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Thomas Mitchell Thomas Mitchell
Author Profile Icon Thomas Mitchell
Thomas Mitchell
Arrow right icon
View More author details
Toc

VM power states

If you manage any number of Azure VMs on a day-to-day basis, you are going to need to understand the different states in which VMs can exist. In this section, I want to briefly touch on the available power states for a VM, and on how to check the current power state of a VMe via PowerShell.

There are seven power states that a VM can exist in:

  • Starting: Indicates that the VM is being started.
  • Running: Indicates that the VM is running.
  • Stopping: Indicates that the VM is being stopped.
  • Stopped: Indicates that the VM is stopped. Note that VMs in the stopped state still incur compute charges.
  • Deallocating: Indicates that the VM is being deallocated.
  • Deallocated: Indicates that the VM is completely removed from the hypervisor but still available in the control plane. VMs in the deallocated state do not incur compute charges.
  • Unknown ( - ): Indicates that the power state of the VM is unknown.

Although most of these are self-explanatory, I wanted to ensure that you were aware of them.

Retrieving the VM's status

Retrieving the status of a VM is rather straightforward. To retrieve the state of a specific virtual machine, use the Get-AzureRmVM command, taking care to specify valid names for the VM and the resource group.

Run the following command to check the status of the myVM virtual machine:

Get-AzureRmVM `
-ResourceGroupName "VMLab" `
-Name "myVM" `
-Status

The command in the preceding example retrieves the current status of the myVM virtual machine. While the output will include quite a bit of information, what we are most concerned about for this exercise is the part that shows whether the VM is running:

The resulting output indicates the current status of the VM.

You have been reading a chapter from
Azure PowerShell Quick Start Guide
Published in: Dec 2018
Publisher: Packt
ISBN-13: 9781789614954
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image