Skip to content

Get licenses of O365 users

Get a list of users and which licenses they’ve got assigned.

First connect to the Microsoft Online environment.

# Import the MSOnline module.
Import-Module MSOnline

# Capture administrative credentials.
$Credential = Get-Credential

# Establishes Online Services connection to Azure Active Directory.
Connect-MsolService -Credential $Credential

Run the script and find out which licenses they have.

# Get online users.
$MsolUsers = Get-MsolUser -All | Select-Object UserPrincipalName, Licenses, isLicensed

ForEach ($MsolUser in $MsolUsers){

if ($MsolUser.isLicensed -eq $True){

$LicencesAsText = $MsolUser.Licenses.AccountSkuId
Write-Host "$($MsolUser.UserPrincipalName) has license: $LicencesAsText" -BackgroundColor Green

}
}
Published inOffice 365

Be First to Comment

Leave a Reply

Your email address will not be published.