Get Microsoft 365 License and Service Plan Counts with PowerShell
Question details
Count assigned Microsoft 365 product licenses and report service plan assignments using PowerShell.

- Product
- Microsoft 365 and Microsoft Graph PowerShell
- Device & OS
- not provided
- Scenario
- An administrator needs tenant-wide counts for product licenses and bundled service plans.
- Observed behavior
- The desired report shows product license counts or successfully provisioned service plans grouped by product.
Use an account authorized to read users, license details, and subscription information in the Microsoft 365 tenant. Install the Microsoft Graph PowerShell SDK and obtain admin consent for the required permissions if your tenant requires it.
Count provisioned service plans by Microsoft 365 product
Use Microsoft Graph PowerShell to export a count of users with successfully provisioned service plans for each product.
This report counts distinct users per product and service plan when the plan's provisioning status is Success. It excludes disabled and pending plans, so it is not a count of every assigned or enabled plan.
A user with the same service plan through multiple products can appear in more than one product group. Do not add those groups together to calculate a tenant-wide unique-user count.
Open PowerShell and run: Connect-MgGraph -Scopes "User.Read.All", "LicenseAssignment.Read.All". Sign in and grant consent if prompted. If the SDK is not installed, first run Install-Module Microsoft.Graph -Scope CurrentUser.
Run Get-MgUserLicenseDetail -UserId "user@domain.com" | Select-Object SkuPartNumber -ExpandProperty ServicePlans to see the product, service plan names, and provisioning statuses for that user.
Run the following script in PowerShell. It retrieves licensed users, groups successfully provisioned plans by product and plan name, and writes the counts to the current folder: $users = Get-MgUser -All -Property Id,UserPrincipalName,AssignedLicenses | Where-Object { $_.AssignedLicenses.Count -gt 0 } $rows = foreach ($user in $users) { foreach ($license in (Get-MgUserLicenseDetail -UserId $user.Id)) { foreach ($plan in $license.ServicePlans) { if ($plan.ProvisioningStatus -eq 'Success') { [pscustomobject]@{ UserId = $user.Id; SkuPartNumber = $license.SkuPartNumber; ServicePlanName = $plan.ServicePlanName } } } } } $rows | Group-Object SkuPartNumber,ServicePlanName | ForEach-Object { $group = $_.Group [pscustomobject]@{ SkuPartNumber = $group[0].SkuPartNumber ServicePlanName = $group[0].ServicePlanName ProvisionedUsers = @($group.UserId | Sort-Object -Unique).Count } } | Export-Csv -Path '.\service-plan-counts.csv' -NoTypeInformation
Open service-plan-counts.csv in a spreadsheet and filter the ServicePlanName or SkuPartNumber column for the service or product you need.

View assigned license counts by product SKU
Use this shorter command when you need product-level license counts rather than counts for individual bundled services.
Review Microsoft 365 License Reports in WPS Office
WPS Office is a free, lightweight Microsoft Office alternative with a familiar interface and compatible file formats for a smooth transition. Use WPS Spreadsheets to review exported license reports; Microsoft Graph remains necessary to retrieve tenant data.

Frequently Asked Questions
How can I check service plans for just one user?
Connect with Connect-MgGraph, then run Get-MgUserLicenseDetail -UserId "user@domain.com" | Select-Object SkuPartNumber -ExpandProperty ServicePlans. Check ServicePlanName and ProvisioningStatus in the output.
Why doesn't a product license count match a service plan count?
A product can bundle several service plans, and a plan may be disabled or still provisioning for some users. The report above counts only plans with a Success provisioning status.
What happened to Get-MsolUser?
Get-MsolUser belongs to the retired MSOnline PowerShell module. Use Microsoft Graph PowerShell commands such as Get-MgUser and Get-MgUserLicenseDetail for current reporting.
Can I count OneDrive or Skype for Business by filtering the report?
Open the CSV and filter ServicePlanName for the identifiers present in your tenant. Some older SKUs use SHAREPOINTENTERPRISE for SharePoint-related services that include OneDrive and MCOSTANDARD for Skype for Business Online. Skype for Business Online has been retired, so historical identifiers may not represent an active service.




