Azure PowerShell – Get basic VM configuration

Summary: This blog post describes an easy way to get basic Azure VM configuration with Azure PowerShell

As an IT-Pro, I love using PowerShell to get easy access to information, without needing to click through interfaces. This is getting more important every day as the User Interface (especially for Azure and Office 365) have been changing quite regularly. Getting information can be hard because of this change.

However, if you are using PowerShell, the way of getting information stays the same, as the core for PowerShell doesn’t change that often and it can be used repeatedly.

Getting basic Azure VM information

Azure gives us great PowerShell cmdlets that help us get the information we need. However, because of the scale of Azure, some information might not be where you expect it to be.
A simple example: If you want to know how many CPU’s or memory have been assigned to your VM, you have to get the “VMSize”, which has its own cmdlet.

This would be:

Get-AzureRmVmSize -Location "West Europe"

.
This produces a list of (in my case) 214 different VM types that are available in the region. Each of these VM types have different configurations.
If you have 100 VMs in Azure, you would have to look up each of the VM types to get the basic information.

Solution
To solve this problem, I wrote a simple to use PowerShell function that gets the information for your specific Azure environment.
The script can be found on GitHub: https://github.com/martensnico/Azure.Helperscripts/blob/master/Get-AzureRMVMInfo.ps1

You can import the script by downloading it and running the following PowerShell (run this from the folder where the script is located):

. .\Get-AzureRMVMInfo.ps1

The cmdlet is now available in your PowerShell session.

Example

Get-AzureRMVM | Get-AzureRMVMInfo | Sort "Internal IP"

This will return a list of all VMs in the current subscription and shows the basic information for these VMs.
Here’s an output example:

Get-AzureRMVMInfo

Help
Additional help is also available by running:

help Get-AzureRMVMInfo

Azure PowerShell help

Leave a Reply

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