This Azure PowerShell article will discuss the syntax and usage of the Get-AzureRmVM PowerShell command with specific examples. We will also discuss how to fix the error Get-AzureRmVM not recognized that I have encountered while executing the Get-AzureRmVM command.
Table of Contents
- Get-AzureRmVM
- Syntax:
- Example: How to get the user-specified properties and instance-level status of the virtual machine?
- Example: How to get only the user-specified properties of the VM?
- Example: How to get the properties of all the VMs under a particular Resource Group?
- Example: How to get all virtual machines in a specific Region?
- Example: How to get all virtual machines under the subscription?
Get-AzureRmVM
The Get-AzureRmVM PowerShell cmdlet helps you get the virtual machine’s properties. It also provides the details of user-specified properties and the instance-level status of the virtual machine. This belongs to AzureRM.Compute module.
Syntax:
The syntax of the Get-AzureRmVM is as below
Get-AzureRmVM[-Status][-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
or,
Get-AzureRmVM
[-YourResourceGroupName] <String>
[-Status]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Or,
Get-AzureRmVM
-Location <String>
[-Status]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Let’s discuss some of the examples below
Example: How to get the user-specified properties and instance-level status of the virtual machine?
You can use the below PowerShell cmdlet to get the virtual machine’s user-specified properties and instance-level status.
PS C:\WINDOWS\system32> Get-AzureRmVM -ResourceGroupName "DemoResourceGroup" -Name "TSinfoVM"
Here, DemoResourceGroup is the name of my Resource Group, and TSinfoVM is the name of my virtual machine.
Example: How to get only the user-specified properties of the VM?
We can also get only the user-specified properties of the VM using the below PowerShell cmdlet. Here, the only difference is we need to append the Status Parameter.
PS C:\WINDOWS\system32> Get-AzureRmVM -ResourceGroupName "DemoResourceGroup" -Name "TSinfoVM" -Status
Example: How to get the properties of all the VMs under a particular Resource Group?
When you need to retrieve the properties of all the virtual machines under a specific Resource Group, you can use the below PowerShell cmdlet.
PS C:\WINDOWS\system32> Get-AzureRmVM -ResourceGroupName "DemoResourceGroup"
Example: How to get all virtual machines in a specific Region?
You can use the below PowerShell cmdlet to retrieve the list of Virtual machines that belong to a specific region or location.
PS C:\WINDOWS\system32> Get-AzureRmVM -Location "eastus"
Example: How to get all virtual machines under the subscription?
Use the below PowerShell cmdlet to get the list of Azure Virtual machines under your subscription
PS C:\WINDOWS\system32> Get-AzureRmVM
I got the get-azureRmvm not recognized error while executing the below cmdlet.
$myVmName = 'MyNewVM'
$myrsgName = 'newresgroup'
$myvm = Get-AzureRmVM –Name $myVmName –ResourceGroupName $myrsgName
$myResource = @{
'ResourceName' = $myVmName
'ResourceType' = 'Microsoft.Compute/virtualMachines'
'ResourceGroupName' = $myrsgName
}
$myvmResource = Get-AzureRmResource @myResource
$myvmId = $vmResource.Properties.VmId

The exact error is
Get-AzureRmVM : The term ‘Get-AzureRmVM’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:7 char:1
- Get-AzureRmVM
~~~~~- CategoryInfo : ObjectNotFound: (Get-AzureRmVM:String) [], CommandNotFoundException
- FullyQualifiedErrorId : CommandNotFoundException
To fix the error Get-AzureRmVM is not recognized as the name of a cmdlet, what we need to do is
Login to the AzureRm Account using the below command.
PS C:\windows\system32> Login-AzureRmAccount
Next, install the AzureRm module using the below cmdlet
PS C:\windows\system32> Install-Module AzureRm
Click on the Yes button from the below pop-up

Now you can see below it started installing the AzureRm module.

It should fix the issue now, but in case you are getting the error “No match was found for the specified search criteria and module name AzureRm”. You can follow my article. No match was found for the specified search criteria and module name ‘AzureAD’ to fix this error.
You may like the following Azure tutorials:
- How to Connect to Azure in PowerShell (And Azure AD)
- How to create a user in Azure active directory
- Azure.psm1 cannot be loaded because running scripts is disabled on this system
In this Azure tutorial, we discussed the syntax and usage of the Get-AzureRmVM PowerShell command with specific examples and how to fix the error Get-AzureRmVM not recognized that I have encountered while executing the Get-AzureRmVM command.. I hope it helped you to fix your issue.
I am Bijay, a Microsoft MVP (10 times) having more than 17 years of experience in the software industry. During my IT career, I got a chance to share my expertise in SharePoint and Microsoft Azure, like Azure VM, Azure Active Directory, Azure PowerShell, etc. I hope you will learn from these Azure tutorials. Read more