Get all user lisences from Office 365 to csv.


Today I had to get a list from Office 365 with UserPrincipalName and MsolAccountSku. So here is the trick-script.

$ReportPath =
Add-Content -value
(“UserPrincipalName”+”,”+”IsLicensed”+”,”+ “Licenses”)
-Path $ReportPath
$AllUsers =
Get-MsolUser -All
foreach ($User
in $AllUsers)
= $User.UserPrincipalName
= $User.IsLicensed
= $User.Licenses.AccountSkuId
 Add-Content -value ($UserPrincipalName+”,”+$IsLicensed+”,”+$Licenses) -Path $ReportPath

Please note that copy/paste could possible break something 🙂
Author: Harri Jaakkonen

Leave a Reply

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