The term ‘Get-AzureRmVM’ is not recognized as the name of a cmdlet

In this azure tutorial, we will discuss how to fix the error, 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.

The term ‘Get-AzureRmVM’ is not recognized as the name of a cmdlet

I got the get-azureRmvm not recognized error while trying to execute the below cmdlet using PowerShell ISE in Azure.

$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 term 'Get-AzureRmVM' is not recognized as the name of a cmdlet
Get-AzureRmVM not recognized

Get-AzureRmVM not recognized

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

The term ‘Get-AzureRmVM’ is not recognized as the name of a cmdlet [Solved]

To fix this 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

 how to fix The term 'Get-AzureRmVM' is not recognized as the name of a cmdlet

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

The term 'Get-AzureRmVM' is not recognized as the name of a cmdlet  how to fix

It should fix the issue now but in case if 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.

The term ‘Get-AzureRmResource’ is not recognized as the name of a cmdlet

I also got this error The term ‘Get-AzureRmResource’ 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.

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

You can see here

The term 'Get-AzureRmResource' is not recognized as the name of a cmdlet

The exact error is

Get-AzureRmResource: The term ‘Get-AzureRmResource’ 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:12 char:18

  • $myvmResource = Get-AzureRmResource @myResource
  • ~~~~~~~
    • CategoryInfo : ObjectNotFound: (Get-AzureRmResource:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

The term ‘Get-AzureRmResource’ is not recognized as the name of a cmdlet [Solved]

To fix this error, you need to follow the same steps like above.

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

 The term 'Get-AzureRmResource' is not recognized as the name of a cmdlet

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

The term 'Get-AzureRmResource' is not recognized as the name of a cmdlet how to fix

It should fix the issue now but in case if 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.

How to check Azure VM status with PowerShell?

We can able to check the Azure VM instance-level status and the properties using Get-AzureRmVM and Get-AzVM PowerShell cmdlets. Let’s discuss one by one as below.

Get azurevm (Get-AzureRmVM )

The Get-AzureRmVM PowerShell cmdlet helps you to get the properties of the virtual machine. 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 like 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 user-specified properties and instance-level status of the virtual machine.

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 have a requirement 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 machine those 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

Get-AzVM

Description

The Get-AzVM PowerShell cmdlet helps you to get the properties of the virtual machine. It also provides the details of user-specified properties and the instance level status of the virtual machine. This exactly works in the same way as Get-AzureRmVM. The Get-AzVM belongs to Az.Compute module.

Syntax:

The syntax of the Get-AzVM is similar to the Get-AzureRmVM PowerShell cmdlet.

Get-AzVM[-Status][-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Or,

Get-AzVM
[-YourResourceGroupName] <String>
[-Status]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]

Or,

Get-AzVM-Location <String>
[-Status]
[-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

well, let’s discuss some of the examples as below

Example: How to get the user-specified properties and instance-level status of the virtual machine using Get-AzVM?

You can use the below PowerShell cmdlet to get the user-specified properties and instance-level status of the virtual machine.

PS C:\WINDOWS\system32> Get-AzVM -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 using Get-AzVM?

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-AzVM -ResourceGroupName "DemoResourceGroup" -Name "TSinfoVM" -Status

Example: How to get the properties of all the VMs under a particular Resource Group using Get-AzVM?

When you have a requirement 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-AzVM -ResourceGroupName "DemoResourceGroup"

Example: How to get all virtual machines in a specific Region using Get-AzVM?

You can use the below PowerShell cmdlet to retrieve the list of Virtual machine those belong to a specific region or location.

PS C:\WINDOWS\system32> Get-AzVM -Location "westus"

Example: How to get all virtual machines under the subscription using Get-AzVM?

Use the below PowerShell cmdlet to get the list of Azure Virtual machines under your subscription

PS C:\WINDOWS\system32> Get-AzVM

Difference between Get-AzureRmVM and Get-AzureVM

  • If you are using the old classic Azure Portal that time you will have to use the Get-AzureVM to get the list of Azure Virtual machines.
  • When you are using the new Azure Portal, you need to use the Get-AzureRmVM i.e with the resource manager to get the list of the Azure Virtual machines.

You may like following Azure tutorials:

In this Azure tutorial, we discussed how to fix the error, The term ‘Get-AzureRmVM’ is not recognized as the name of a cmdlet, and The term ‘Get-AzureRmResource’ is not recognized as the name of a cmdlet, and then we have discussed How to check Azure VM status with PowerShell?, Get azurevm (Get-AzureRmVM ), Get-AzVM. Finally, we have discussed the Difference between Get-AzureRmVM and Get-AzureVM.I hope it helped you to fix your issue.