One-Liner: Get O365 User Licenses

Here’s a great one liner I use all the time to run a report get our user’s O365 licenses.

This should go without saying, but make sure you’ve installed the MSOnline module. Then connect with Connect-MSOLService.

Get-MSOLuser -All | Where-Object {$_.licenses -ne $null} | Select-Object UserPrincipalname, @{Name='Licenses'; Expression={$_.licenses.accountskuid}}

You should get an output similar to this:

You could add a Export-Csv or Convertto-JSON | Out-file .\filename.json if you wanted to have a report you wanted to send off or plug into another piece of software respectively.

Leave a Reply

Your email address will not be published. Required fields are marked *