Get a list of licensed users
- ToddimusPrime
- Jun 9, 2021
- 1 min read
Here's a quick one for you. Do you ever need to export a list of which users have a particular license in Office 365?
First, connect to Azure Active Directory in PowerShell
Connect-MsolServiceNow you need to figure out what the Account Sku ID is for the license you care about
Get-MsolAccountSkuYou'll get a list of all your licenses' Account Sku IDs. Why can't they just be named something normal? I mean seriously, what's up with this?

The tenant name has been redacted, but it's part of the Sku ID, so don't forget about it in the next step
Take the Sku you want, and plug it into this. Feel free to add or remove some user properties from the 'Select-Object' portion.
$sku = "<Account Sku ID goes here>"
Get-MsolUser -All | ?{$_.isLicensed -eq "TRUE" -and ($_.Licenses | ?{ $_.AccountSkuId -eq $sku}).Length -gt 0} | Select-Object DisplayName,UserPrincipalName



Comments