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
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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