Muokkaa

Jaa


Install Azure Active Directory PowerShell for Graph

Important

Azure AD Powershell is planned for deprecation on March 30, 2024. For more details on the deprecation plans, see the deprecation update. We encourage you to continue migrating to Microsoft Graph PowerShell, which is the recommended module for interacting with Azure AD. In addition, Microsoft Graph PowerShell allows you access to all Microsoft Graph APIs and is available on PowerShell 7. For answers to frequent migration queries, see the Migration FAQ.

You can use the Azure Active Directory PowerShell module version for Graph for Azure AD administrative tasks such as user management, domain management and for configuring single sign-on. The cmdlets listed here are different from the MSOnline cmdlets which are part of Azure Active Directory PowerShell version 1.0.

The Azure AD PowerShell for Graph module has two versions: a Public Preview version and a General Availability (GA) version. It isn't recommended to use the Public Preview version for production scenarios.

Download the modules from the PowerShell Gallery use the following;

Azure Active Directory PowerShell for Graph release version history

The release history for the Azure AD module and the Azure AD Preview module is here:azure active directory powershell for graph: version release history.

Installing the Azure AD Module

Prerequisites

The Azure AD module is supported on the following Windows operating systems with the default version of Microsoft .NET Framework and Windows PowerShell:

  • Windows 8.1
  • Windows 8
  • Windows 7
  • Windows Server 2012 R2,
  • Windows Server 2012
  • Windows Server 2008 R2.

Note

The Azure AD PowerShell module is not compatible with PowerShell 7. It is only supported in PowerShell 5.1.

To install the General Availability version of the module, run:

Install-Module AzureAD

To install the public preview release, run:

Install-module AzureADPreview

You cannot install both the preview version and the GA version on the same computer at the same time.

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).

With the latest PowerShellGet module, you can:

Check out the Getting Started page for more information on how to use PowerShellGet commands with the Gallery. You can also run Update-Help -Module PowerShellGet to install local help for these commands.

Supported Operating Systems

The PowerShellGet module requires PowerShell 3.0 or newer.

Therefore, PowerShellGet requires one of the following operating systems:

  • Windows 10
  • Windows 8.1 Pro
  • Windows 8.1 Enterprise
  • Windows 7 SP1
  • Windows Server 2016 TP5
  • Windows Server 2012 R2
  • Windows Server 2008 R2 SP1

PowerShellGet also  requires .NET Framework 4.5 or above. You can install .NET Framework 4.5 or above from here.

Updating the Azure AD Module

To check the version of the module installed on your computer run this command:

Get-Module AzureADPreview

ModuleType Version Name                ExportedCommands
---------- ------- ----                ----------------
Binary     2.0.0.7 azureadpreview     {Add-AzureADAdmini...

To update the version of the Azure AD PowerShell module on your computer, rerun the Install-Module cmdlet:

Install-Module AzureADPreview

This command checks the PowerShell gallery to see if a newer version is available. If yes, the newer than the one installed on your computer.

Connect to Azure AD

Before you can run any of the cmdlets discussed in this article, you must first connect to your online service. To do so, run the cmdlet Connect-AzureAD at the Windows PowerShell command prompt. You'll then be prompted for your credentials. If you want, you can supply your credentials in advance, for example:

$AzureAdCred = Get-Credential
Connect-AzureAD -Credential $AzureAdCred

The first command prompts for credentials and stores them as $AzureAdCred. The next command uses those credentials as $azureadcred to connect to the service.

Note

The Azure AD and Azure AD Preview modules comprise of cmdlets with different naming conventions i.e. -AzureAD and -AzureADMS. The -AzureAD cmdlets connect to the Azure AD Graph endpoint https://graph.windows.net while the -AzureADMS cmdlets make calls to the Microsoft Graph endpoint graph.microsoft.com. Authentication is handled silently when you change the calls from one endpoint to another and you are not prompted for the credentials again.

To connect to a specific environment of Azure Active Directory, use the AzureEnvironment parameter, as follows:

Connect-AzureAD -AzureEnvironment "AzureGermanyCloud"

This example connects your PowerShell session to the German AzureAD environment. See Connect-AzureAD for more information.

Next steps