
In this Azure PowerShell article, we will discuss how to get the list of virtual machines under your Azure subscription.
Table of Contents
- Azure PowerShell List Virtual Machines
- Get-AzVM
- Syntax:
- Get the lists of Virtual Machines under your Azure Subscription
- Get the lists of Virtual Machines properties under a specific Resource Group
- Get the lists of Virtual Machines under a specific Location
- Get the lists of virtual machines based on Filter conditions
- Get the instance view properties of a Specific Azure Virtual Machine
- Get the instance view properties and model view properties of a Specific Azure Virtual Machine
- Wrapping Up
Azure PowerShell List Virtual Machines
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:
The syntax of the Get-AzVM is as below.
Get-AzVM
[[-ResourceGroupName] <String>]
[[-Name] <String>]
[-Status]
[-UserData]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
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.

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
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 a specific Resource Group.
PS C:\WINDOWS\system32> Get-AzVM -ResourceGroupName "Your Resource Group Name"
Example: The below cmdlet will show you the list of Azure virtual machine properties under the Demo123 resource group.
PS C:\WINDOWS\system32> Get-AzVM -ResourceGroupName "Demo123"
You can see the output here.

Get the lists of Virtual Machines under a specific Location
When you have the requiremen to get the lists of Azure Virtual machines under a specific location, you can use the below Azure PowerShell cmdlet.
PS C:\WINDOWS\system32> Get-AzVM -Location "Location/region Name"
Example:The below Azure PowerShell cmdlet will get you the list of all the Virtual Machines from the East US2 region.
PS C:\WINDOWS\system32> Get-AzVM -Location "EastUS2"
You can see the output here as below

Get the lists of virtual machines based on Filter conditions
You can retrieve the lists of Azure Virtual Machines based on certain filter conditions. You can use the Azure Powershell cmdlet like below.
PS C:\WINDOWS\system32> Get-AzVM -Name VirtualMachineName*
Example: The below Azure cmdlet will help you to retrieve the lists of Azure Virtual Machines whose name starts with TsInfoVM.
PS C:\WINDOWS\system32> Get-AzVM -Name TsInfoVM*
You can check the output as below

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 a specific Azure Virtual Machine under a particular resource group.
Get-AzVM -ResourceGroupName "Resource Group Name" -Name "Virtual Machine name" -Status
Example: You can execute the below Azure PowerShell cmdlet to get the instance properties of TsInfoVM1 under the Demo123 resource group.
Get-AzVM -ResourceGroupName "Demo123" -Name "TsInfoVM1" -Status
Once I have executed the above Azure PowerShell cmdlet, you can able to see the output below
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
see the same as below.

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 "Resource Group Name" -Name "Virtual Machine name"
Example: You can execute the below Azure PowerShell cmdlet to get the instance and model view properties of TsInfoVM1 under the Demo123 resource group.
Get-AzVM -ResourceGroupName "Demo123" -Name "TsInfoVM1"
After executing the above Azure PowerShell cmdlet, I got the below 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 it below

You may also like following the below articles
- How to Upload and Download File From Azure Blob Storage Using C# and PowerShell
- Azure Active Directory Module for Windows Powershell
- How to create an Azure web app using PowerShell
- The term ‘get-aduser’ is not recognized as the name of a cmdlet in Windows 10 PowerShell
- az account show
- Azure PowerShell Get VM Public IP
Wrapping Up
In this article, we have discussed the usage and examples of Get-AzVM Azure PowerShell cmdlet. This is how you can get the lists of Azure Virtual machines using Azure PowerShell.