How to use PowerShell to install the Azure Active Directory module

How to use PowerShell to install the Azure Active Directory module

You'll need to install the Azure AD Module if you wish to use PowerShell to interface with your Azure AD environment. With this module, you may use PowerShell to control your whole Azure Active Directory.

It's important to note right away that PowerShell 7 does not support the Azure AD Module. After June 30, 2022, Microsoft plans to deprecate Azure AD Graph (the endpoint that the Azure AD Module accesses).

In this article, I'll show you how to use PowerShell to install and update the Azure AD Module.

Install the Azure Active Directory module.

We'll use PowerShell to install the Azure Module. The General Availability (GA) version is suitable for production environments. You can also install the Public Preview version of the module if you want to try out new features.

Open PowerShell with Administrator privileges.

— Right-click (or press Windows key + X) on your Start menu. On Windows 11, select Windows PowerShell (admin) or Windows Terminal (admin).


Open PowerShell with Administrator privileges.

— Right-click (or press Windows key + X) on your Start menu. On Windows 11, select Windows PowerShell (admin) or Windows Terminal (admin)

"Install-Module AzureAD"

and type Y to install the NuGet provider if prompted.


Untrusted Repository can be accessed.

You'll be asked if you wish to install from an Untrusted Repository when NuGet is installed. To install the Azure AD Module, press Y.


Connect to Azure Active Directory

PowerShell now has the AzureAD module installed. You can use the following command to connect to Azure AD and test the module.

"Connect-AzureAD"


Install the AzureADPreview Module on your computer.

You can use the same instructions to install the preview version of the module. Only use AzureADPreview: in place of the module name.

"Install-Module AzureADPreview"

Update the Azure Active Directory Module

Updating the Azure AD Module in PowerShell is much the same as reinstalling it. We may start by using the Get-Module cmdlet to see what version you presently have installed.

"Get-Module -Name AzureADPreview"

Then, in the PSGallery repository, look for the latest version:

"Find-module -Name AzureADPreview -Repository psgallery"


It's a good idea to upgrade the module if you have an older version installed. This way, you'll have access to the module's most recent cmdlets.

To update the module, we'll use the Update-Module cmdlet:

"Update-Module -Name AzureADPreview"

To install the module from an untrusted source, press Y once again.


Final Thoughts

Is the Azure AD module still the simplest approach to manage our Azure Active Directory users using PowerShell for the time being? Keep in mind, however, that the module may cease to function after June 2022.

In this post, you may learn more about the new Microsoft Graph SDK module.

Please leave a remark below if you have any questions.