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.
- 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
- Connect to Azure Active Directory (Azure AD).
connect-msolservice
- List the SKUs (Stock keeping units) that the company Owns using
Get-MsolAccountSku
Get-MsolAccountSku
- 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.