
In this Azure PowerShell article, we will discuss how to get the list of virtual machines under your Azure subscription using the Get-AzVM PowerShell command.
Table of Contents
- Get-AzVM
- Syntax of Get-AzVM
- Example-1: Get the lists of Virtual Machines under your Azure Subscription
- Example-2: Get the lists of Virtual Machines properties under a specific Resource Group
- Example 3: Get the lists of Virtual Machines under a specific Location
- Example 4: Get the lists of virtual machines based on Filter conditions
- Example 5: Get the instance view properties of a Specific Azure Virtual Machine
- Example 6: Get the instance view properties and model view properties of a Specific Azure Virtual Machine
- Wrapping Up
Get-AzVM
The Get-AzVM command is used to get the lists of Virtual machines or the properties of the Azure Virtual Machines present under your Azure subscription.
Syntax of Get-AzVM
The syntax of the Get-AzVM is as follows.
Get-AzVM
Get-AzVM [[-ResourceGroupName] <String>]
Get-AzVM
[[-ResourceGroupName] <String>]
[[-Name] <String>]
Example-1: Get the lists of Virtual Machines under your Azure Subscription
You can execute the below Azure PowerShell cmdlet to retrieve the lists of Virtual Machines present under your Azure Subscription.
PS C:\WINDOWS\system32> Get-AzVM
Once I have executed this command, I got two virtual machines as the output. Check out the below output.
ResourceGroupName Name Location VmSize OsType NIC ProvisioningSt
ate
----------------- ---- -------- ------ ------ --- --------------
DEMO123 TsInfoVM1 eastus Standard_B1ms Windows tsinfovm1353 Succeeded
TSINFOVM2_GROUP TsInfoVM2 eastus2 Standard_B1ms Windows tsinfovm2533 Succeeded
You can find the same output in the screenshot below, where I have executed the above command and got the expected output where we got the azure VM list.

Example-2: Get the lists of Virtual Machines properties under a specific Resource Group
You can use the below Azure PowerShell cmdlet to retrieve the properties of all the Virtual Machines under the specified Resource Group.
PS C:\WINDOWS\system32> Get-AzVM -ResourceGroupName "Demo123"
You can see the output in the screenshot below, where I have executed the above command and got the expected output.

Example 3: Get the lists of Virtual Machines under a specific Location
When you have the requirement to list all VMs in Azure under the specified location, you can use the below Azure PowerShell cmdlet.
PS C:\WINDOWS\system32> Get-AzVM -Location "EastUS2"
After executing the above Get-AzVM PowerShell command, I got the below expected output. Check out the screenshot below.

Example 4: Get the lists of virtual machines based on Filter conditions
You can get the Azure VM details based on specific filter conditions below. You can use the Azure Powershell cmdlet like below.
PS C:\WINDOWS\system32> Get-AzVM -Name TsInfoVM*
After executing the above PowerShell script to get the list of all VMs in Azure, I got the expected output below. You can see the below screenshot for your reference.

Example 5: Get the instance view properties of a Specific Azure Virtual Machine
You can also use the below Azure PowerShell cmdlet to retrieve the instance properties of the specified Azure Virtual Machine under a particular resource group.
Get-AzVM -ResourceGroupName "Demo123" -Name "TsInfoVM1" -Status
Once I have executed the above Azure PowerShell cmdlet, you can see the output below that I got as expected.
ResourceGroupName : Demo123
Name : TsInfoVM1
ComputerName : TsInfoVM1
OsName : Windows Server 2019 Datacenter
OsVersion : 10.0.17763.2928
HyperVGeneration : V2
BootDiagnostics :
Disks[0] :
Name : TsInfoVM1_OsDisk_1_59b9dc46c8664601aa097db870d093c5
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Time : 6/4/2022 11:42:10 AM
VMAgent :
VmAgentVersion : 2.7.41491.1044
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Ready
Message : GuestAgent is running and processing the extensions.
Time : 6/4/2022 12:51:34 PM
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Time : 6/4/2022 11:43:16 AM
Statuses[1] :
Code : PowerState/running
Level : Info
DisplayStatus : VM running
Check out the screenshot below, where I have executed the above command and got the expected output.

Example 6: Get the instance view properties and model view properties of a Specific Azure Virtual Machine
You can use the below Azure PowerShell cmdlet to view the model and instance view properties for a specific Azure Virtual Machine under a particular Resource Group.
Get-AzVM -ResourceGroupName "Demo123" -Name "TsInfoVM1"
After executing the above Azure PowerShell cmdlet, I got the below-expected output
ResourceGroupName : Demo123
Id : /subscriptions/1cdf4300-dee5-4518-9c9c-feaa72a5cbd1/resourceGroup
s/Demo123/providers/Microsoft.Compute/virtualMachines/TsInfoVM1
VmId : 2ee09ab1-f11f-4760-a8bc-6510283b7c1b
Name : TsInfoVM1
Type : Microsoft.Compute/virtualMachines
Location : eastus
Tags : {}
DiagnosticsProfile : {BootDiagnostics}
HardwareProfile : {VmSize}
NetworkProfile : {NetworkInterfaces}
OSProfile : {ComputerName, AdminUsername, WindowsConfiguration, Secrets,
AllowExtensionOperations, RequireGuestProvisionSignal}
ProvisioningState : Succeeded
StorageProfile : {ImageReference, OsDisk, DataDisks}
You can see the below screenshot where I have executed the above Azure PowerShell command and got the

If you are facing any issues or errors while executing the Get-AzVM command, you can check out, The term ‘Get-VM’ is not recognized as the name of a cmdlet.
You may also like following the articles below
Wrapping Up
In this article, we have discussed the syntax and usage and examples of Get-AzVM Azure PowerShell cmdlet. This is how you can get the lists of Azure Virtual machines using the Azure PowerShell command Get-AzVM.

I am Rajkishore, and I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machine, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.