The term ‘Remove-AzureVM’ is not recognized as the name of a cmdlet

In this azure tutorial, we will discuss how to fix the error, The term ‘Remove-AzureVM’ 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. 

which comes while trying to execute the Remove-AzureVM using PowerShell ISE in Azure.

The term ‘Remove-AzureVM’ is not recognized as the name of a cmdlet, function, script file, or operable program

Recently, while executing the command Remove-AzureVM to remove one of my Azure Virtual machine(VM), I got the above error.

PS C:\windows\system32> Remove-AzureVM -Name "MYNewVM"

See here

The term 'Remove-AzureVM' is not recognized as the name of a cmdlet

The exact error message is as below

Remove-AzureVM : The term ‘Remove-AzureVM’ 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:2 char:1

  • Remove-AzureVM -Name “MYNewVM”
  • ~~~~~~
    • CategoryInfo : ObjectNotFound: (Remove-AzureVM:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

To fix this error you need to follow the below steps:

Step-1:

Open the Windows PowerShell or PowerShell ISE app as an administrator.

Step-2:

Connect to the AzureAD.

PS C:\windows\system32> Connect-AzureAD
The term 'Remove-AzureVM' is not recognized as the name of a cmdlet, function, script file, or operable program

Step-3:

Now install the Azure Module.

PS C:\windows\system32> Import-Module Azure
Remove-AzureVM  The term 'Remove-AzureVM' is not recognized as the name of a cmdlet

Step-4:

Now click on the Yes button on the below pop up.

Remove-AzureVM  The term 'Remove-AzureVM' is not recognized as the name of a cmdlet

Step-5:

You can see now it started the installation of Azure module.

Remove-AzureVM  The term 'Remove-AzureVM' is not recognized as the name of a cmdlet

After installing the Azure module successfully, I tried to execute the Remove-AzureVM to remove one of my Azure Virtual machine(VM).

Oops again i got the below error

The ‘Remove-AzureVM’ command was found in the module ‘Azure’, but the module could not be loaded. For more information, run ‘Import-Module Azure’.

see here

The 'Remove-AzureVM' command was found in the module 'Azure', but the module could not be loaded. For more information, run 'Import-Module Azure'.

To fix this, We need to Import the Azure Module

Import the Azure Module using the below cmdlet in your PowerShell window or PowerShell ISE.

PS C:\windows\system32> Import-Module Azure
The 'Remove-AzureVM' command was found in the module 'Azure', but the module could not be loaded.

Oops while executing the above command, i got the below error

Import-Module : File C:\Program Files\WindowsPowerShell\Modules\Azure\5.3.0\Azure.psm1 cannot be loaded because running scripts is disabled on this system. For more information,
see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

To fix this issue, you need to execute the below cmdlets or You can also refer to Powershell error – Az.Resources.psm1 cannot be loaded because running scripts is disabled on this system to fix this issue.

To fix the above issue run the below command first.

PS C:\windows\system32> Set-ExecutionPolicy RemoteSigned
Azure.psm1 cannot be loaded because running scripts is disabled on this system

After running the above command, again try importing the Azure Module using the below cmdlet in your PowerShell window or PowerShell ISE. Now you can able to see it imported the Azure module sucessfully.

PS C:\windows\system32> Import-Module Azure
cannot be loaded because running scripts is disabled on this system

Now when I ran again the command Remove-AzureVM to remove one of my Azure Virtual machine(VM)

PS C:\windows\system32> Remove-AzureVM -Name "MYNewVM"

See here

Cannot be loaded because running scripts is disabled on this system

This is how we can fix this issue!!!

You may like following Azure tutorials:

In this Azure tutorial, we discussed how to fix the error, The term ‘Remove-AzureVM’ is not recognized as the name of a cmdlet. I hope it helped you to fix your issue.