The term ‘Get-AzHost’ is not recognized

In this Azure PowerShell article, we will discuss how to fix the error The term ‘Get-AzHost’ is not recognized as the name of a cmdlet that I got while running the Get-AzHost PowerShell command.

The term ‘Get-AzHost’ is not recognized

Recently, I was trying to execute the ‘Get-AzHost’ PowerShell Command and I got this error. The complete error message was as below

Get-AzHost : The term ‘Get-AzHost’ 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:1 char:1

  • Get-AzHost
  • ~~
    • CategoryInfo : ObjectNotFound: (Get-AzHost:String) [], CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

You can see the below screenshot for your reference.

The term 'Get-AzHost' is not recognized

The term ‘Get-AzHost’ is not recognized [Solved]

I have followed the below steps to fix this error and successfully ran the Get-AzHost PowerShell command.

  1. Run the PowerShell ISE with Run as Administrator mode.
  2. Execute the below Azure PowerShell command to install the Az module.
Install-Module -Name Az -Repository PSGallery -Force

3. After the Successful installation of the Az module, I tried running the Get-AzHost PowerShell module but I got the below error.

“The ‘Get-AzHost’ command was found in the module ‘Az. Compute’, but the module could not be loaded.” check out the below screenshot.

The 'Get-AzHost' command was found in the module 'Az.Compute'

To fix this issue, I ran the PowerShell command below

Import-Module Az.Compute
Get-AzHost

After running, the above Command, I got the Running scripts is disabled on this system error which I fixed by following this article.

After fixing the above error, I can execute the below PowerShell command Successfully without any issues and get the Expected output. Check out the below screenshot for your reference.

Import-Module Az.Compute
Get-AzHost
'Get-AzHost' is not recognized

Conclusion

In this Azure PowerShell article, We discussed how to fix the error The term ‘Get-AzHost’ is not recognized as the name of a cmdlet which I got while running the Get-AzHost PowerShell command. Thanks for reading this article !!!