Get-MgUserLicenseDetail

What is Get-MgUserLicenseDetail?

The Get-MgUserLicenseDetail cmdlet in Microsoft Graph PowerShell retrieves license details for a specific user in Microsoft 365. It provides information about assigned licenses and service plans, enabling administrators to understand a user’s subscription entitlements.


Why Use Get-MgUserLicenseDetail?

This cmdlet is highly useful for automation and reporting. IT admins can:

  • Quickly check license assignments for individual users.
  • Retrieve service plans and usage details for compliance.
  • Automate reporting of license details across the entire tenant.
  • Export license data for auditing and management.

By using Get-MgUserLicenseDetail, organizations can streamline license tracking and ensure efficient subscription management.


Prerequisites

Before running the cmdlet, ensure you have the Microsoft Graph PowerShell module installed and required permissions granted.

Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.Read.All"

How to Use Get-MgUserLicenseDetail?

Basic syntax:

Get-MgUserLicenseDetail -UserId <GUID>

You can pass a User Principal Name (UPN) or User ID to fetch license details for a specific user.


Get-MgUserLicenseDetail Examples

  • Get License Details of a Specific User
  • Get-MgUserLicenseDetail -UserId samadmin@7xh7fj.onmicrosoft.com
  • Getting the Service Plans
  • Get-MgUserLicenseDetail -UserId "samadmin@7xh7fj.onmicrosoft.com" | Format-List
  • Get License Details of Multiple Users
  • $users = @("kimmy@7xh7fj.onmicrosoft.com","samadmin@7xh7fj.onmicrosoft.com","LeeG@7xh7fj.onmicrosoft.com")
    foreach($user in $users) {
        Get-MgUserLicenseDetail -UserId $user
    }
                                                
  • Exporting License Details of Multiple Users to CSV File
  • $users = Get-MgUser -All
    foreach($user in $users) {
        Get-MgUserLicenseDetail -UserId $user.Id | Export-Csv -Path "d:/WeekyUserLicenseDetails.csv" -NoTypeInformation -Append
    }
                                                

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