You are trying to connect to Azure AD using the Azure AD PowerShell using the command ‘Connect-AzureAD‘ however you have encountered an issue. The issue is that when you enter the command into your PowerShell session, you get the following error:

“Connect-AzureAD: The term ‘Connect-AzureAD’ is not recognized as the name of a cmdlet, function, script file, or operable program.”

In this post I am going to show you how to fix the Connect-AzureAD is not recognized error.

Did you know?

Microsoft Graph PowerShell will soon be the default method of connecting to Azure AD with PowerShell. Check out my guide on installing the Microsoft Graph PowerShell module here.

What does this error mean?

This error could be caused by a few different problems, such as that the Azure AD PowerShell module is not currently available in your PowerShell session and it needs to be imported. Or that that module is not yet installed. However if you have installed the module in the past and it has only just stopped working, it could be corrupt which may require you to re-install the module onto your system. 

Regardless of this issue, below I will show you how to resolve the error: The term ‘Connect-AzureAD’ is not recognized as the name of a cmdlet, function, script file, or operable program.

How to fix the error: The term 'Connect-AzureAD' is not recognized

1. Start by running PowerShell as an administrator. You can do this by searching for ‘Windows PowerShell’ in your start menu and right-clicking PowerShell, then selecting ‘Run as Administrator’.

Run PowerShell as an administrator
Run PowerShell as an administrator

2. Once PowerShell has opened, use the Install-Module AzureAD cmdlets with the -force parameter.

The force parameter will ensure the command runs, even if it was likely to fail. For example, if PowerShell thinks the AzureAD module is installed, but we know it is corrupt, using -force will run the command anyway and re-download, then install all the necessary files to re-install the AzureAD module.

Install-Module AzureAD -force

3. You can verify the AzureAD module installed successfully by using the ‘get-installedmodule’ command.

Get-InstalledModule
Get-InstalledModule
Get-InstalledModule

Similarly, if you have many modules installed, you can filter your results by using the Where-Object cmdlet with the -match parameter.

Get-Installedmodule | Where-Object {$_.Name -match "AzureAD"}
Get-InstalledModule Where-Object AzureAD
Get-InstalledModule Where-Object AzureAD

4. You can also verify the Connect-AzureAD cmdlet is present on your system by using the Find-Command cmdlet and the Where-Object filter.

Find-Command | Where-Object {$_.Name -match "Connect-AzureAD"}

In your results, you may find multiple similar cmdlets to our search term and your results should look like the below.

Connect-AzureAD
Connect-AzureAD

5. Now running the ‘Connect-AzureAD’ command and you will be prompted with the modern authentication prompt for Azure AD

Connect-AzureAD

There you have it! you can now successfully connected to Azure AD using PowerShell.