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

Subscribe to Stay Connected

Thank you for visiting TechPress 👍. When you subscribe to the blog, email notification ✉ will be sent to you when a new blog post is published. We do not spam or sell your email address. You can unsubscribe at any time.

guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments