Install The Azure Active Directory Module For Windows Powershell

  1. Install Azure Powershell Module

Azure AD PowerShell module was earlier installed by a standard .msi package. Now you can install it using one PowerShell command. However, installation requires PowerShell 5 or newer.

Find Remote Server Adminstration Tools - Role Adiminstration Tools - AD DS and AD LDS Tools - Active Directory Module for Windows PowerShell, and turn it on. You may need to restart your computer. I don't recall. Finally, import the module, and use it normally. The Azure AD module is distributed using the PowerShell gallery. Installing items from the Gallery requires the latest version of the PowerShellGet module, which is available in Windows 10, in Windows Management Framework (WMF) 5.0, or in the MSI-based installer (for PowerShell 3 and 4).

Module installation requires PowerShell 5 or later which is included in Windows 10 & Server 2016. If you have previous version of Windows, you need to install Windows Management Framework 5.1 here.

To install the latest Azure AD PowerShell module, enter the following commands as an administrator.

Azure AD PowerShell v1 (MsOnline)

If you haven’t used the Install-Module command earlier, you might not have NuGet provider. Just click the Yes to continue.

You might also get the following error message stating that PSGallery is untrusted. This is okay so you may safely click the yes button.

Now you are ready to connect to Office 365!

Azure AD PowerShell v2 (AzureAD)

Now you are ready to connect to Office 365!

Azure AD PowerShell v2 preview (AzureADPreview)

Note! AzureAD Preview has same commands than AzureAD, only the module name is different. Therefore, theycannot be installed in the same computer together.

Now you are ready to connect to Office 365!

-->

Summary: Connect to your Office 365 organization using Office 365 PowerShell to perform administration tasks from the command line.

Office 365 PowerShell lets you manage your Office 365 settings from the command line. Connecting to Office 365 PowerShell is a simple process where you install the required software and then connect to your Office 365 organization.

There are two versions of the PowerShell module that you use to connect to Office 365 and administer user accounts, groups, and licenses:

  • Azure Active Directory PowerShell for Graph (cmdlets include AzureAD in their name)
  • Microsoft Azure Active Directory Module for Windows PowerShell (cmdlets include MSol in their name)

As of the date of this article, the Azure Active Directory PowerShell for Graph module does not completely replace the functionality in the cmdlets of Microsoft Azure Active Directory Module for Windows PowerShell module for user, group, and license administration. In many cases, you need to use both versions. You can safely install both versions on the same computer.

Tip

New to PowerShell? See a video Overview of PowerShell, brought to you by LinkedIn Learning.

What do you need to know before you begin?

  • Estimated time to complete: 5 minutes

  • You can use the following versions of Windows:

    • Windows 10, Windows 8.1, Windows 8, or Windows 7 Service Pack 1 (SP1)

    • Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012, or Windows Server 2008 R2 SP1

      Note

      Use a 64-bit version of Windows. Support for the 32-bit version the Microsoft Azure Active Directory Module for Windows PowerShell was discontinued in October of 2014.

  • These procedures are intended for users who are members of an Office 365 admin role. For more information, see About Office 365 admin roles.

Connect with the Azure Active Directory PowerShell for Graph module

Commands in the Azure Active Directory PowerShell for Graph module have AzureAD in their cmdlet name.

For

For procedures that require the new cmdlets in the Azure Active Directory PowerShell for Graph module, use these steps to install the module and connect to your Office 365 subscription.

Note

See Azure Active Directory PowerShell for Graph module for information about the support for different versions of Microsoft Windows.

Step 1: Install required software

These steps are required once on your computer, not every time you connect. However, you'll likely need to install newer versions of the software periodically.

  1. Open an elevated Windows PowerShell command prompt (run Windows PowerShell as an administrator).

  2. In the Administrator: Windows PowerShell command window, run this command:

If prompted about installing a module from an untrusted repository, type Y and press ENTER.

Step 2: Connect to Azure AD for your Office 365 subscription

To connect to Azure AD for your Office 365 subscription with an account name and password or with multi-factor authentication (MFA), run one of these commands from a Windows PowerShell command prompt (it does not have to be elevated).

Office 365 cloudCommand
Office 365 Worldwide (+GCC)Connect-AzureAD
Office 365 operated by 21 VianetConnect-AzureAD -AzureEnvironmentName AzureChinaCloud
Office 365 GermanyConnect-AzureAD -AzureEnvironmentName AzureGermanyCloud
Office 365 U.S. Government DoD and Office 365 U.S. Government GCC HighConnect-AzureAD -AzureEnvironmentName AzureUSGovernment

In the Sign into your account dialog box, type your Office 365 work or school account user name and password, and then click OK.

If you are using MFA, follow the instructions in the additional dialog boxes to provide more authentication information, such as a verification code.

After connecting, you can use the new cmdlets for the Azure Active Directory PowerShell for Graph module.

Connect with the Microsoft Azure Active Directory Module for Windows PowerShell

Commands in the Microsoft Azure Active Directory Module for Windows PowerShell have Msol in their cmdlet name.

Step 1: Install required software

These steps are required once on your computer, not every time you connect. However, you'll likely need to install newer versions of the software periodically.

  1. Install the 64-bit version of the Microsoft Online Services Sign-in Assistant: Microsoft Online Services Sign-in Assistant for IT Professionals RTW.

  2. Install the Microsoft Azure Active Directory Module for Windows PowerShell with these steps:

For
  • Open an elevated Windows PowerShell command prompt (run Windows PowerShell as an administrator).
  • Run the Install-Module MSOnline command.
  • If prompted to install the NuGet provider, type Y and press ENTER.
  • If prompted to install the module from PSGallery, type Y and press ENTER.

Step 2: Connect to Azure AD for your Office 365 subscription

To connect to Azure AD for your Office 365 subscription with an account name and password or with multi-factor authentication (MFA), run one of these commands from a Windows PowerShell command prompt (it does not have to be elevated).

Office 365 cloudCommand
Office 365 Worldwide (+GCC)Connect-MsolService
Office 365 operated by 21 VianetConnect-MsolService -AzureEnvironment AzureChinaCloud
Office 365 GermanyConnect-MsolService -AzureEnvironment AzureGermanyCloud
Office 365 U.S. Government DoD and Office 365 U.S. Government GCC HighConnect-MsolService -AzureEnvironment USGovernment

In the Sign into your account dialog box, type your Office 365 work or school account user name and password, and then click OK.

If you are using MFA, follow the instructions in the additional dialog boxes to provide more authentication information, such as a verification code.

How do you know this worked?

Install Azure Powershell Module

If you don't receive any errors, you connected successfully. A quick test is to run an Office 365 cmdlet—for example, Get-MsolUser —and see the results.

If you receive errors, check the following requirements:

  • A common problem is an incorrect password. Run Step 2 again. and pay close attention to the user name and password you enter.

  • The Microsoft Azure Active Directory Module for Windows PowerShell requires that the Microsoft .NET Framework 3.5.x feature is enabled on your computer. It's likely that your computer has a newer version installed (for example, 4 or 4.5.x), but backwards compatibility with older versions of the .NET Framework can be enabled or disabled. For more information, see the following topics:

    This EXE installation package can automatically detect and install the 32 bit or 64 bit for your Microsoft Office applications according to your computer circumstance, so we recommend you to download and use EXE installation package. To deploy the software with MSI for 64-bit version of Office 2010, 2013, 2016 and Office 365, you should download the 64-bit MSI. If you have Microsoft Office 2003, 2007 or 32-bit Microsoft Office 2010, 2013, 2016 and Office 365, you should download the 32-bit MSI. Only Microsoft Office 2010, 2013, 2016 and Office 365 has 32-bit and 64-bit version. Free download microsoft access 2003 installer facebook.

    • For Windows Server 2012 or Windows Server 2012 R2, see Enable .NET Framework 3.5 by using the Add Roles and Features Wizard

    • For Windows 7 or Windows Server 2008 R2, see You can't open the Azure Active Directory Module for Windows PowerShell

    • For Windows 10, Windows 8.1, and Windows 8, see Install the .NET Framework 3.5 on Windows 10, Windows 8.1, and Windows 8

  • Your version of the Microsoft Azure Active Directory Module for Windows PowerShell might be out of date. To check, run the following command in Office 365 PowerShell or the Microsoft Azure Active Directory Module for Windows PowerShell:

    If the version number returned is lower than the value 1.0.8070.2, uninstall the Microsoft Azure Active Directory Module for Windows PowerShell and install the latest version from the link in Step 1.

  • If you receive a connection error, see this topic:'Connect-MsolService: Exception of type was thrown' error.

See also