Table of Contents
In this article, we’ll look at how to install the AzureAD PowerShell module, connect to your Azure Active Directory tenant and get some information from Azure. Microsoft currently allows you to use two PowerShell modules to connect to Entra ID:
- MSOnline is an old module to manage the Azure/Office 365 from PowerShell. MSOnline module appeared about 6 years ago and is not developed by Microsoft now.
- Azure Active Directory PowerShell for Graph (AzureAD) is a modern PowerShell module for interacting with Azure infrastructure. The module is being actively developed, new features are being added (analogs of almost all MSOnline cmdlets are available).
Requirements
- You should use PowerShell on Windows 10 or Windows 11. Be aware that you need to install .NET Framework 4.5 or later.
- An internet connection is required. TCP port 80 must be opened to connect from your local machine to the destination host.
Install Entra ID PowerShell module
1. Open an elevated Windows PowerShell window (run Windows PowerShell as an administrator).
2. Run the following commands at once to install Entra ID PowerShell module.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name AzureAD;
Import-Module AzureAD;
Connect-AzureAD
3. The cmdlet will prompt you to enter the credentials you want to use to access the AzureAD directory. In this example, we are using admin account [email protected] to access our tenant.
You can get information about the current Azure tenant as follows:
Get-AzureADTenantDetail
PS C:\> Get-AzureADTenantDetail
ObjectId DisplayName VerifiedDomain
-------- ----------- --------------
7299a0f5-xxxx-xxxx-9826-a7daff5d06b2 Bon Ben leoguides.me
To get a list of available licenses in your Office 365 (Microsoft 365) subscription, the following cmdlet is used:
Get-AzureADSubscribedSku | select SkuPartNumber, ConsumedUnits
PS C:\> Get-AzureADSubscribedSku | select SkuPartNumber, ConsumedUnits
SkuPartNumber ConsumedUnits
------------- -------------
WIN_ENT_E5 2
WINDOWS_STORE 0
TEAMS_EXPLORATORY 1
SPE_E3 16
If you have an older version of the Entra ID installed, you can update it:
Update-Module -Name AzureAD
To disconnect from Azure in your PowerShell session, run the command below:
Disconnect-AzureAD