Powershell – Export the list of users and licenses assigned to them from Office 365

|
, | TechPress-KBID-104
Home » Office 365 » Powershell – Export the list of users and licenses assigned to them from Office 365

Summary: PowerShell Commands to determine the Office 365 Licenses that have been assigned to users. Connect to Exchange Online (EXO)

$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

References:  Product names and service plan identifiers for licensing https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/licensing-service-plan-reference

Leave a Reply