To get all licensed users in Office 365, use the Get-MsolUser
cmdlet in PowerShell to retrieve the list of all users and check the IsLicensed
property of the users equal to true.
Get-MsolUser -All | where {$_.isLicensed -eq $true}
In the above PowerShell script, the Get-MsolUser cmdlet uses the -All
parameter to retrieve all users in the Azure AD and pipes them to the Where condition.
The Where
condition checks if the IsLicensed
property of the user is equal to true and returns all licensed users in Azure AD.
The output of the above PowerShell script that lists all licensed user accounts in your organization is given below.
To export all licensed users in Office 365 to the CSV file, run the following command.
Get-MsolUser -All | where {$_.isLicensed -eq $true} | Export-Csv -Path D:\licensed_users.csv -NoTypeInformation
This command exports all licensed users in the Azure AD to the csv file.
Cool Tip: How to get the licenses assigned to a user in Microsoft Office 365 with PowerShell!
Conclusion
I hope the above article on how to use Get-MsolUser cmdlet to get all licensed users in Office 365 is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.