We may fall in a situation to get a list of Office 365 users with a specific license plan to decide license usage or some other need. We can easily find users who has a specific office 365 license feature using Azure AD Powershell commands.
Before proceed, first run the below command to connect Azure AD Powershell module.
Import-Module MSOnline Connect-MsolService
We can run Get-MsolAccountSku cmdlet to get a list of the available licenses in your Office 365 tenant.
Get-MsolAccountSku
Once run the above command, copy the the AccountSkuId value for the license that you want to filter.
Now copy the below script and replace AccountSkuId of license that you copied from the above step and run the modified script to list users who are assigned to a specific license in Office 365.
Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -eq "tenant:EMSPREMIUM"}
Export list of users who has a specific license to CSV file.
Run the below command to export office 365 users based on required or selected license plan.
Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -eq "tenant:EMSPREMIUM"} | Select-Object UserPrincipalName, DisplayName | Export-Csv "C:\O365Users.csv" -NoTypeInformation -Encoding UTF8
You can use the app Microsoft Office 365 Manager to get a clear picture of Office 365 license assignments. You can also generate actionable reports such as licensed users, users by a specific license. Read the below post to know more details.
Microsoft Office 365 License Usage Reports ยป