Export the list of users and assigned licenses from Office 365

In this blog post, we will see how to Export the list of users and assigned licenses from Microsoft 365 / Office 365 using powershell. We will be using get-msoluser command for this. Let’s check the steps.

  1. Connect to Exchange Online Powershell.
$mycred = Get-Credential <Global Administrator User ID> 
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $mycred -Authentication Basic -AllowRedirection 
Import-PSSession $Session
  1. Connect to Azure Active Directory (Azure AD).
connect-msolservice
  1. List the SKUs (Stock keeping units) that the company Owns using Get-MsolAccountSku
Get-MsolAccountSku
  1. Export the Users with Licenses assigned to them to a CSV file.
Get-msoluser | ft UserPrincipalName, @{L='Licenses Assigned'; E={($_.licenses).Accountskuid}} | Out-File c:\temp\LicenseExport.csv

To find the Product names and service plan identifiers for licensing. Please visit below Microsoft link for Licensing service plan reference.

https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-service-plan-reference

Leave a Comment