Fix “Connect-AzureAD : The term ‘Connect-AzureAD’ is not recognized as the name of a cmdlet, function, script file, or operable program.” Error
Problem: When trying to connect to Azure AD from PowerShell, using: “Connect-AzureAD” cmdlet, received an error: “Connect-AzureAD: The term ‘Connect-AzureAD’ is not recognized as the name of a cmdlet, function, script file, or operable program.”
Solution for Connect-AzureAD not recognized Issue:
The error “Connect-AzureAD : The term ‘Connect-AzureAD’ is not recognized as the name of a cmdlet” typically occurs when the AzureAD PowerShell module is not installed or not imported properly. Here are a few steps that you can try to resolve this error:
Install the Azure AD Module:
- Open PowerShell as an administrator, Enter:
Install-Module AzureAD
- Confirm the installation by entering “A” – Yes to All.
A similar error “Get-MsolUser : The term “Get-MsolUser” 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.” may occur when you try to execute the cmdlet from Azure AD PowerShell Module V1, and you got to install the MSOnline module to resolve.
Installing the PowerShell module to connect to Azure AD Office 365 is here: How to Connect to Azure AD using PowerShell?
A few more troubleshooting steps:
If you are still getting the same error, here is the troubleshooting checklist.
- Try Importing the AzureAD PowerShell module: Import-Module AzureAD
- Make sure that you are running PowerShell as an administrator.
- Check your PowerShell version: The AzureAD module requires at least PowerShell version 5.1, so ensure you are running a compatible version of PowerShell.
- Check for other modules that may conflict with AzureAD, and if there are any, remove or update them
- Try to run the command in a different PowerShell session or in a different machine.