Licenses Usage Count Monthly

Mark Joseph Bacor 5 Reputation points
2023-03-21T16:16:42.95+00:00

Hi Microsoft Support,

Just asking if there's a way to export or generate a report for Licensing Usage Count per month in Microsoft 365.

I tried the following command line but it seems Get-MsolUserlicensedetails does not recognized.

# Connect to Microsoft 365
Connect-MsolService

# Set the start and end dates for the report (in this example, March 1 to March 31, 2023)
$startDate = Get-Date "2023-03-01"
$endDate = Get-Date "2023-03-31"

# Retrieve all users and their license details
$users = Get-MsolUser -All | ForEach-Object {
    $user = $_.UserPrincipalName
    $licenseDetail = Get-MsolUserLicenseDetail -UserPrincipalName $user
   
    # Filter the license details to only include assignments in March 2023
    $marchAssignments = $licenseDetail | Where-Object { $_.AssignedTimestamp -ge $startDate -and $_.AssignedTimestamp -lt $endDate.AddDays(1) }
   
    # If the user has any assignments in March 2023, output their UPN and the license details
    if ($marchAssignments) {
        [PSCustomObject]@{
            User = $user
            Assignments = $marchAssignments.LicenseName -join ","
            AssignedTimestamps = $marchAssignments.AssignedTimestamp -join ","
        }
    }
}

# Output the report to a CSV file
$users | Export-Csv -Path "C:\Reports\March2023LicenseAssignments.csv" -NoTypeInformation
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,761 questions
0 comments No comments
{count} vote

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.