Deprecation Notice (2026):
TheAzureADandAzureADPreviewPowerShell modules have been officially retired and disconnected. The Azure AD Graph API (graph.windows.net) has reached end-of-life.
> All Microsoft cloud identity administration now uses the Microsoft Graph PowerShell SDK. Below is the updated connection process.
Modern Method: Installing and Connecting to Microsoft Graph PowerShell
The Microsoft Graph PowerShell SDK is the official replacement for managing Microsoft Entra ID (Azure AD) and Microsoft 365 tenants.
1. Install the Microsoft Graph Authentication & Core Modules
Open PowerShell (PowerShell 7.x recommended) as an administrator:
POWERSHELL
# Install core Graph authentication and user management modules
Install-Module Microsoft.Graph.Authentication -Repository PSGallery -Scope CurrentUser -Force
Install-Module Microsoft.Graph.Users -Repository PSGallery -Scope CurrentUser -Force
2. Connect Interactively with Multi-Factor Authentication (MFA)
To connect interactively with device code or browser-based MFA:
POWERSHELL
Connect-MgGraph -Scopes "User.Read.All", "Directory.Read.All" -NoWelcome
3. Verify Connection and Active Context
Once authenticated, verify your active tenant and account:
POWERSHELL
Get-MgContext
To list users in your directory:
POWERSHELL
Get-MgUser -Top 10 -Property DisplayName, UserPrincipalName, AccountEnabled
To disconnect:
POWERSHELL
Disconnect-MgGraph
Historical Reference: The Retired AzureAD Module (Pre-2024)
The instructions below are preserved for historical reference only. Install-Module AzureAD and Connect-AzureAD will no longer connect to Microsoft cloud services.
In older environments, administrators installed the AzureAD module:
POWERSHELL
# Historical command - do not use in production
Install-Module AzureAD
Import-Module AzureAD
Connect-AzureAD