How to Use Get-MgUserLicenseDetail to Fetch User License Details?

Managing Microsoft 365 user licenses is an essential part of any IT admin's daily responsibilities. Whether you're auditing license assignments, troubleshooting access issues, or simply keeping track of usage, having visibility into individual user licenses is critical.

That’s where the Get-MgUserLicenseDetail cmdlet in Microsoft Graph PowerShell comes in.

What is Get-MgUserLicenseDetail?

The Get-MgUserLicenseDetail cmdlet retrieves detailed information about the Microsoft 365 licenses assigned to a specific user. This cmdlet provides insights, such as service plans included in the license and their status (Enabled/Disabled).

Why Use Get-MgUserLicenseDetail?

Get-MgUserLicenseDetail help IT administrators with the following:

  • Audit-Ready Data: Shows what services a user is licensed for (like Exchange, Teams, SharePoint).
  • Troubleshooting Tool: Helps pinpoint if users lack access to specific services due to disabled plans.
  • Bulk License Checks: Ideal for exporting license data for all users.
  • No Need to Access Admin Portals: Manage everything directly from PowerShell.

Cmdlet Syntax

  • Get-MgUserLicenseDetail -UserId <String>

Usage Examples

By Passing UPN

Get-MgUserLicenseDetail -UserId "samadmin@7xh7fj.onmicrosoft.com"

This returns all assigned licenses along with service plan details for the specified user.

By Passing User ID

Get-MgUserLicenseDetail -UserId "1111-2222-4555-67676"

If you have the Azure AD Object ID, this method is equally effective.

Fetching License Details for All Users

To audit all user license details and export them into a CSV file:

$users = Get-MgUser
foreach ($user in $users){
    Get-MgUserLicenseDetail -UserId $user.Id | Export-Csv -Path "WeeklyUserLicenseDetails.csv" -NoTypeInformation -Append
}
                                        

This script iterates through every user in your tenant and appends their license detail to a report file.

Frequently Asked Questions

  • What’s the difference between Get-MgUser and Get-MgUserLicenseDetail?
  • Get-MgUser shows whether a user is licensed but not what licenses they have.
Get-MgUserLicenseDetail breaks down which licenses and services are assigned to the user.

  • Can I use email instead of UPN?
  • Yes, as long as the email matches the UPN (UserPrincipalName), it works.

  • Why do some service plans show “Disabled”?
  • These are part of the license but have been manually turned off for that user.

  • How do I identify which license corresponds to a product (like E5)?
  • Match the SKU ID or SKU Part Number from the output with Microsoft’s SKU documentation or use the Get-MgSubscribedSku cmdlet.

Use Cases

  • License Audits: Generate reports for compliance or financial analysis.
  • Service Access Issues: Identify disabled services affecting end-user functionality.
  • License Optimization: Find unused or underutilized services.
  • Automated Reporting: Schedule scripts to export weekly or monthly reports.

Conclusion

The Get-MgUserLicenseDetail cmdlet is your go-to PowerShell tool for license transparency across your Microsoft 365 environment. From troubleshooting to automation, it empowers you with the details that matter most—without needing to click through multiple admin portals.

If you're serious about license visibility and control, this cmdlet should be a core part of your scripting toolkit.

Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Your Site Name. All Rights Reserved. Design by HTML Codex