How to check and know which licenses were assigned to users in the past days, weeks and months in M365 tenant and what are the ways to export the report as well for the same apart from Entra ID audit logs as it only give 30 days of report by default if we

Mytoast Admin 290 Reputation points
2024-09-30T17:00:10.7333333+00:00

How to check and know which licenses were assigned to users in the past days, weeks and months in M365 tenant and what are the ways to export the report as well for the same apart from Entra ID audit logs as it only give 30 days of report by default if we were to export it so it would be better to get that report via MS Graph API or PowerShell?

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,956 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,055 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,822 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hitesh Pachipulusu - MSFT 2,145 Reputation points Microsoft Vendor
    2024-10-08T11:21:04.7+00:00

    Hello Mytoast Admin,

    Thank you for reaching out to Microsoft Support!

    To check which licenses were assigned to users in your Microsoft 365 (M365) tenant, you can use PowerShell and the Microsoft Graph API. Here are the steps:

    1. View License Details Using PowerShell:
      • Connect to your M365 tenant using PowerShell with the necessary permissions.
      • List the license plans for your tenant using the command:
             Get-MgSubscribedSku
        
      • To list the services available in each licensing plan, use:
             $allSKUs = Get-MgSubscribedSku -Property SkuPartNumber, ServicePlans
             $allSKUs | ForEach-Object { Write-Host "Service Plan:" $_.SkuPartNumber $_.ServicePlans | ForEach-Object {$_} }
        
      • To list the licenses assigned to a specific user account, use:
             Get-MgUserLicenseDetail -UserId "<user sign-in name (UPN)>"
        
    2. View Licensed and Unlicensed Users:
      • To find unlicensed users (those without any assigned licenses), run:
             Get-MgUser -Filter 'assignedLicenses/$count eq 0' -ConsistencyLevel eventual -CountVariable unlicensedUserCount -All
             Write-Host "Found $unlicensedUserCount unlicensed users."
        
      • To find licensed users (those with assigned licenses), run:
             Get-MgUser -Filter 'assignedLicenses/$count ne 0' -ConsistencyLevel eventual -CountVariable licensedUserCount -All -Select UserPrincipalName, DisplayName, AssignedLicenses | Format-Table -Property UserPrincipalName, DisplayName, AssignedLicenses
             Write-Host "Found $licensedUserCount licensed users."
        

    Remember to replace <user sign-in name (UPN)> with the actual user’s UPN.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.