Error when you try to run Azure Active Directory module for Windows PowerShell cmdlets: The term <cmdlet name> is not recognized

Original product version:   Cloud Services (Web roles/Worker roles), Microsoft Entra ID, Microsoft Intune, Azure Backup, Office 365 Identity Management
Original KB number:   2669552

Symptoms

When you try to run Microsoft Azure Active Directory module for Windows PowerShell cmdlets, you receive the following error message:

The term <cmdlet name> 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.

For example, you might see the following similar message:

The term 'Connect-MsolService' 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:20
+ Connect-MsolService <<<<
+ CategoryInfo : ObjectNotFound: (Connect-MsolService:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Cause

This issue can occur if the Azure Active Directory module for Windows PowerShell isn't loaded correctly.

Resolution

To resolve this issue, follow these steps.

  1. Install the Azure Active Directory module for Windows PowerShell on the computer (if it isn't already installed). To install the Azure Active Directory module for Windows PowerShell, see Manage Microsoft Entra ID using Windows PowerShell.

  2. Select Start > All Programs, select Windows Azure Active Directory, and then select Windows Azure Active Directory module for Windows PowerShell.

  3. At the Windows PowerShell command prompt, type Get-Module, and then press Enter.

  4. In the output, check that the MSOnline module is present. The output should look similar to the following one:

    Module Type Name Exported Commands
    -------------- -------- ----------------
    Binary MSOnline {Add-MsolRoleMember, Remove-MsolContact...
    

    If the MSOnline module isn't present, use Windows PowerShell to import the MSOnline module. To do it, follow these steps:

    1. Connect to Exchange Online by using remote PowerShell. For more info about how to do it, see Connect to Exchange Online Using Remote PowerShell.

    2. Type the following cmdlet, and then press Enter:

      Import-Module MSOnline
      

Contact us for help

If you have questions or need help, create a support request, or ask Azure community support. You can also submit product feedback to Azure feedback community.