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.

Use the Microsoft Graph PowerShell SDK

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 {$_}
}

Use the Azure Active Directory PowerShell for Graph module

First, connect to your Microsoft 365 tenant.

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

Get-AzureADSubscribedSku | Select SkuPartNumber

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

$allSKUs=Get-AzureADSubscribedSku
$licArray = @()
for($i = 0; $i -lt $allSKUs.Count; $i++)
{
$licArray += "Service Plan: " + $allSKUs[$i].SkuPartNumber
$licArray +=  Get-AzureADSubscribedSku -ObjectID $allSKUs[$i].ObjectID | Select -ExpandProperty ServicePlans
$licArray +=  ""
}
$licArray

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

$userUPN="<user account UPN, such as belindan@contoso.com>"
$licensePlanList = Get-AzureADSubscribedSku
$userList = Get-AzureADUser -ObjectID $userUPN | Select -ExpandProperty AssignedLicenses | Select SkuID 
$userList | ForEach { $sku=$_.SkuId ; $licensePlanList | ForEach { If ( $sku -eq $_.ObjectId.substring($_.ObjectId.length - 36, 36) ) { Write-Host $_.SkuPartNumber } } }

Use the Microsoft Azure Active Directory Module for Windows PowerShell

First, connect to your Microsoft 365 tenant.

Next, run this command to list the licensing plans that are available in your organization.

Get-MsolAccountSku

Note

PowerShell Core does not support the Microsoft Azure Active Directory Module for Windows PowerShell module and cmdlets with Msol in their name. To continue using these cmdlets, you must run them from Windows PowerShell.

Next, run this command to list the services that are available in each licensing plan, and the order in which they are listed (the index number).

(Get-MsolAccountSku | where {$_.AccountSkuId -eq "<AccountSkuId>"}).ServiceStatus

Use this command to list the licenses that are assigned to a user, and the order in which they are listed (the index number).

Get-MsolUser -UserPrincipalName <user account UPN> | Format-List DisplayName,Licenses

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-MsolUser -UserPrincipalName <user account UPN>).Licenses[<LicenseIndexNumber>].ServiceStatus

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-MsolUser -UserPrincipalName belindan@litwareinc.com).Licenses.ServiceStatus

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-MsolUser -UserPrincipalName belindan@litwareinc.com).Licenses[0].ServiceStatus

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

$userUPN="<user account UPN>"
$AllLicenses=(Get-MsolUser -UserPrincipalName $userUPN).Licenses
$licArray = @()
for($i = 0; $i -lt $AllLicenses.Count; $i++)
{
$licArray += "License: " + $AllLicenses[$i].AccountSkuId
$licArray +=  $AllLicenses[$i].ServiceStatus
$licArray +=  ""
}
$licArray

See also

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

Manage Microsoft 365 with PowerShell

Getting started with PowerShell for Microsoft 365