Retrieve All Account License And Service Details In Office 365 Using Azure Active Directory PowerShell

In this article, I have included a whole load of blog examples on how to connect to your Office 365 account and retrieve account details like license name, service plan, licensed users, and external users. You have to follow below instructions for better results.

• Connect to AzureAD
• PowerShell code

Connect to AzureAD :

1. Run Windows PowerShell as an administrator.

2. In that command window, run “Install-Module -Name AzureAD” to install the AzureAD, if it is not installed on your end. If it shows a message about installing a module from an untrusted repository, then type “Y” and press Enter button.

3. Then run the command “Connect-AzureAD“. It will prompt to sign in to your Microsoft account. Type your Office 365 account user name and password and click Next.

4. Then run the command “Install-Module MSOnline” to install MSOnline on your end. If it prompts to install the NuGet provider, type ‘Y’. If it prompts to install the module from PSGallery, type ‘Y’ and press ENTER.

5. Run the “Connect-MsolService” command and then provide your credentials and click on next.

PowerShell Code :

The below code retrieves the details of license name, licensed users, external users, and services plan of your Office365 Account.

 $credential = Get-Credential
Connect-MsolService -Credential $credential 

  #Retrieve license list present inside tenant
  $license = Get-MsolAccountSku
  for($i = 0; $i -lt $license.Count; $i++) 
           $nameLicense = $licenseLists[$i]

           #Retrieve License Name
           Write-Host "License Name ="$nameLicense.SkuPartNumber

           #Retrieve assigned users count
           Write-Host "Assigned Users =" $nameLicense.ConsumedUnits  

   $extUserCount = Get-MsolAccountSku | Where-Object {$_UserPrincipalName -like "*#EXT#*"} 
   Write-Host "External User = " $extUserCount.Count

   #Show the service status of Tenant
   Get-MsolAccountSku | Select -ExpandProperty ServiceStatus
   sleep 10

The out-put will be like the below image.

• Get license and users details Using PowerShell Azure Active Directory.
• Retrieve license name and assigned users by Connecting Azure Active Directory.
• Retrieve all account license and service details in Office 365 using Azure Active Directory PowerShell.
• Get service plan and license details of Office 365 Using MsolService.


Add Your Comments

Your email address will not be published. Required fields are marked *