connect-azaccount not found as the name of a cmdlet

Execute the following PowerShell script in PowerShell gives not recognized for Connect-AzAccount

connect-azaccount

Connect-AzAccount : The term ‘Connect-AzAccount’ 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.

What is Connect-AzAccount

The connect-azaccount is used to connect to Azure with an authenticated account which you can use with your Powershell cmdlets.

Connect-AzAccount
Connect-AzAccount

Documenation: https://learn.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-9.1.0

Solution

The connect-azaccount is part of the ‘Az’ package and needs to be installed. Open Powershell and depending on your security on your machine you might need to run is as administrator.

Install-Module Az

The installation can take a few minutes before complete. Afterwards you should be able to run your Connect-AzAccount command