The term 'Get-AzVM' is not recognized as the name of a cmdlet
Diagnoses the PowerShell error where Az module cmdlets like Get-AzVM are not found. Use when an agent sees this in Windows PowerShell or PowerShell 7. Covers installing the Az module, module autoload issues, and AzureRM vs Az confusion. Not for az CLI errors.
The term 'Get-AzVM' is not recognized as the name of a cmdlet
TL;DR
The Az PowerShell module is not installed (or not loaded) in your session. Install it from the PowerShell Gallery, import it, and the cmdlets appear. Do not confuse this with the az CLI; they are different tools.
The error
The term 'Get-AzVM' is not recognized as the name of a cmdlet, function, script file, or operable program.Fix it
- Install the module:
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force. Expected: the install completes without errors. - Import it:
Import-Module Az. Expected: no output, meaning success. - Verify:
Get-Command Get-AzVM. Expected: it resolves to the Az.Compute cmdlet. - Connect:
Connect-AzAccount. Expected: interactive login succeeds. - Retry your command. Expected:
Get-AzVMreturns your VMs.
When to use this
- An agent sees "not recognized as the name of a cmdlet" for any Get-Az, New-Az, or Set-Az* command.
- Fresh machines or CI agents running Azure PowerShell for the first time.
When NOT to use this
- "'az' is not recognized". That is the Azure CLI, a separate install.
- AzureRM cmdlets (Get-AzureRmVM). Those are the retired module; migrate to Az.
Compatibility
- PowerShell 5.1 and 7+, Az module (current). AzureRM is retired and should not be installed.
Variant phrasings
- "The term 'Connect-AzAccount' is not recognized"
- Any "not recognized as the name of a cmdlet" for Az.* commands
Root cause
Windows ships no Azure modules. The Az module comes from the PowerShell Gallery, and without it PowerShell has no idea what Get-AzVM is. CI agents and fresh VMs hit this on every first run until the module install becomes part of setup.
Edge cases
- Both AzureRM and Az installed side by side cause conflicts. Uninstall AzureRM.
- Execution policy can block the install.
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserfirst if needed.