View Microsoft 365 account license and service details with PowerShell

This article applies to both Microsoft 365 Enterprise and Office 365 Enterprise.

In Microsoft 365, licenses from licensing plans (also called SKUs or Microsoft 365 plans) give users access to the Microsoft 365 services that are defined for those plans. However, a user might not have access to all the services that are available in a license that's currently assigned to them. You can use PowerShell for Microsoft 365 to view the status of services on user accounts.

For more information about licensing plans, license, and services, see View licenses and services with PowerShell.

View account license and service details using Microsoft Graph PowerShell

First, connect to your Microsoft 365 tenant.

Reading user properties including license details requires the User.Read.All permission scope or one of the other permissions listed in the 'Get a user' Graph API reference page.

Connect-Graph -Scopes User.ReadWrite.All, Organization.Read.All

Next, list the license plans for your tenant with this command.

Get-MgSubscribedSku

Use these commands to list the services that are available in each licensing plan.

$allSKUs = Get-MgSubscribedSku -Property SkuPartNumber, ServicePlans 
$allSKUs | ForEach-Object {
    Write-Host "Service Plan:" $_.SkuPartNumber
    $_.ServicePlans | ForEach-Object {$_}
}

Use these commands to list the licenses that are assigned to a user account.

Get-MgUserLicenseDetail -UserId "<user sign-in name (UPN)>"

For example:

Get-MgUserLicenseDetail -UserId "belindan@litwareinc.com"

To view services for a user account

To view all the Microsoft 365 services that a user has access to, use the following syntax:

(Get-MgUserLicenseDetail -UserId <user account UPN> -Property ServicePlans)[<LicenseIndexNumber>].ServicePlans

This example shows the services to which the user BelindaN@litwareinc.com has access. This shows the services that are associated with all licenses that are assigned to her account.

(Get-MgUserLicenseDetail -UserId belindan@litwareinc.com -Property ServicePlans).ServicePlans

This example shows the services that user BelindaN@litwareinc.com has access to from the first license that's assigned to her account (the index number is 0).

(Get-MgUserLicenseDetail -UserId belindan@litwareinc.com -Property ServicePlans)[0].ServicePlans

To view all the services for a user who has been assigned multiple licenses, use the following syntax:

$userUPN="<user account UPN>"
$allLicenses = Get-MgUserLicenseDetail -UserId $userUPN -Property SkuPartNumber, ServicePlans
$allLicenses | ForEach-Object {
    Write-Host "License:" $_.SkuPartNumber
    $_.ServicePlans | ForEach-Object {$_}
}

See also

Manage Microsoft 365 user accounts, licenses, and groups with PowerShell

Manage Microsoft 365 with PowerShell

Getting started with PowerShell for Microsoft 365