This article describes the Get-AzVM cmdlet and how to use it to retrieve virtual machines (VMs) in Azure.
Gets virtual machines.
Get-AzVM [-Name ] [-ResourceGroupName ] [-Status] [-DisplayHint ] []
Get-AzVM [-ResourceGroupName ] -VirtualMachineId []
Get-AzVM [-SubscriptionId ] [-VirtualMachineScaleSetVMId ] []
Get-AzVM [-VirtualMachineScaleSetId ] [-VirtualMachineScaleSetVM ] []
Get-AzVM [-VirtualMachineScaleSetVMId ] []
The Get-AzVM cmdlet retrieves information about one or more virtual machines (VMs) in Azure. You can specify the VMs to retrieve by name, resource group, or VM ID.
By default, Get-AzVM retrieves basic information about the VM. You can use the -Status parameter to retrieve the current running status of the VM.
| Parameter | Type | Description |
|---|---|---|
-Name |
String | Specifies the name of the VM to retrieve. |
-ResourceGroupName |
String | Specifies the name of the resource group that contains the VM. |
-Status |
Switch | Retrieves the running status of the VM. |
-DisplayHint |
Microsoft.Azure.Commands.Compute.Models.DisplayHint | Specifies the format in which to display the VM. Possible values are 'ComputeReservation', 'BareMetalInstance', 'VirtualMachine'. |
-VirtualMachineId |
String | Specifies the ID of the VM. |
-SubscriptionId |
String | Specifies the ID of the Azure subscription. |
-VirtualMachineScaleSetVMId |
String | Specifies the ID of a VM within a Virtual Machine Scale Set. |
-VirtualMachineScaleSetId |
String | Specifies the ID of the Virtual Machine Scale Set. |
-VirtualMachineScaleSetVM |
String | Specifies the name of a VM within a Virtual Machine Scale Set. |
-CommonParameters |
System.Management.Automation.Language.CommandMetadata | Common cmdlets such as -Verbose, -Debug, -ErrorAction, -WarningAction, -InformationAction, -OutVariable. |
This command retrieves all VMs in the specified resource group.
Get-AzVM -ResourceGroupName "MyResourceGroup"
This command retrieves a specific VM named "MyVM" in the "MyResourceGroup" resource group.
Get-AzVM -ResourceGroupName "MyResourceGroup" -Name "MyVM"
This command retrieves a specific VM and its current running status.
Get-AzVM -ResourceGroupName "MyResourceGroup" -Name "MyVM" -Status
This command retrieves all VMs across all resource groups in the current subscription.
Get-AzVM