Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitLet's explore the Get-MgUserLicenseDetail cmdlet, a powerful tool in Microsoft Graph PowerShell that enables administrators to manage and retrieve license details for users in Microsoft 365. Whether you're auditing license usage, managing license assignments, or integrating license data into automated workflows, Get-MgUserLicenseDetail is an essential cmdlet to master.
The Get-MgUserLicenseDetail cmdlet retrieves detailed information about the licenses assigned to a user in Microsoft 365. This information includes the specific licenses and service plans assigned to the user.
To use the Get-MgUserLicenseDetail cmdlet,
Here’s the basic syntax of the Get-MgUserLicenseDetail cmdlet: Get-MgUserLicenseDetail -UserId <String>
[<CommonParameters>]
You should pass in the User Id or the UserPrincipalName to the Get-MgUserLicenseDetail cmdlet.
You can also pass -All to Get-MgUserLicenseDetail cmdlet. In this case, the console requires you to supply the UserPrincipalName or User Id to get the user license details.
You can also get the license details of multiple users by looping the user list and executing Get-MgUserLicenseDetail cmdlet.
$users = @("kimmy@7xh7fj.onmicrosoft.com","samadmin@7xh7fj.onmicrosoft.com","LeeG@7xh7fj.onmicrosoft.com")
foreach($user in $users) {
Get-MgUserLicenseDetail -UserId $user
}
The best way to get license of multiple users is to use Get-MgUser cmdlet along with Get-MgUserLicenseDetail cmdlet and export the license details to a CSV file.
$users = Get-MgUser -All
foreach($user in $users) {
Get-MgUserLicenseDetail -UserId $user.Id | Export-Csv -Path "d:/WeekyUserLicenseDetails.csv" -NoTypeInformation -Append
}
If you format-list the output from Get-MgUserLicenseDetail cmdlet, you'll get the service plans associated with the user.
Get-MgUserLicenseDetail -UserId "samadmin@7xh7fj.onmicrosoft.com" | Format-List
Here are some tips to keep in mind while using the Get-MgUserLicenseDetail cmdlet in Microsoft Graph PowerShell:
No, Get-MgUserLicenseDetail
works on a per-user basis. You need to loop through each user to gather license details in bulk.
Yes, the ServicePlans
property in the output shows enabled or disabled status for individual services tied to the license.
Get-MgUserLicenseDetail?
This typically happens when the user does not have any license assigned or if the wrong user ID was specified.
Error Message | Cause | Solution |
---|---|---|
Resource not found for the segment ‘userId’ | Invalid or misspelled user ID or UPN | Ensure the user exists and pass the correct UserId parameter. Try using:Get-MgUser -UserPrincipalName <UPN> to validate.
|
Access denied. Check permissions and try again. | Missing Graph API permissions. | Make sure your app or session has the required delegated or application permission:User.Read.All or Directory.Read.All .
|
Empty output despite valid user | The user does not have any licenses assigned. | Confirm the license assignment using:Get-MgUser -UserId
|
Get-MgUserLicenseDetail not recognized |
The module or version may not support the cmdlet. |
Ensure you're using the latest version of the Microsoft.Graph module and that it's properly imported. Run: Update-Module Microsoft.Graph if needed.
|
Get-MgUserLicenseDetail
cmdlet returns a detailed list of enabled service plans for each license assigned to the user — including services like Exchange, Teams, and SharePoint.Get-MgUserLicenseDetail
will return an empty array — not an error.Get-MgUserLicenseDetail
cmdlet can be used to generate license reports that help with internal compliance checks or billing audits.© m365corner.com. All Rights Reserved. Design by HTML Codex