Back to script samples page
Report on Office 365 licensed users

This script will allow you to view a report on licensed users in Office 365.

In this script we set the maximum number of results to 10,000 users.

#Connecting to Azure Active Directory

#This first command will import the Azure Active Directory module into your PowerShell session.
Import-Module MSOnline

#Capture administrative credential for future connections.
$credential = get-credential

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

#Return first 10,000 licensed users
Get-MsolUser -maxresults 10000 | Where-Object {$_.isLicensed -eq $true -and $_.Licenses[0].ServiceStatus[3].ProvisioningStatus -ne "Disabled"}
Downloaded 579 times
- - - - - (0)