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.
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" -StatusExample: 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-AzureRmVMI 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-AzureRmAccountNext, install the AzureRm module using the below cmdlet
PS C:\windows\system32> Install-Module AzureRmClick on the Yes button from the below pop-up

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