Hi,
Today I had to get a list from Office 365 with UserPrincipalName and MsolAccountSku. So here is the trick-script.
$ReportPath =
“c:userlist.csv”
“c:userlist.csv”
Add-Content -value
(“UserPrincipalName”+”,”+”IsLicensed”+”,”+ “Licenses”)
-Path $ReportPath
(“UserPrincipalName”+”,”+”IsLicensed”+”,”+ “Licenses”)
-Path $ReportPath
$AllUsers =
Get-MsolUser -All
Get-MsolUser -All
foreach ($User
in $AllUsers)
in $AllUsers)
{
$UserPrincipalName
= $User.UserPrincipalName
= $User.UserPrincipalName
$IsLicensed
= $User.IsLicensed
= $User.IsLicensed
$Licenses
= $User.Licenses.AccountSkuId
= $User.Licenses.AccountSkuId
Add-Content -value ($UserPrincipalName+”,”+$IsLicensed+”,”+$Licenses) -Path $ReportPath
}
Please note that copy/paste could possible break something 🙂
Cheers,