Microsoft 365 License Utilization Script: Generate Interactive HTML Reports

Listen to this Post

Check out this Microsoft 365 License Utilization script that creates an interactive HTML report: Microsoft 365 License Utilization Script. This PowerShell script provides insights into the license utilization of your Microsoft 365 tenant. The script is available on the PowerShell Gallery and can be installed and run to generate a detailed report in seconds.

You Should Know:

Here are some PowerShell commands and practices to help you get started with the script and related tasks:

1. Install the Script from PowerShell Gallery:

Install-Script -Name M365LicenseUtilization -Force

2. Run the Script to Generate the Report:

.\M365LicenseUtilization.ps1 -OutputPath "C:\Reports\LicenseReport.html"

3. Check Microsoft 365 License Details:

Get-MgSubscribedSku | Select SkuPartNumber, SkuId, ConsumedUnits, PrepaidUnits

4. Filter Enabled Licenses:

$licenses = Get-MgSubscribedSku | Where-Object { $_.CapabilityStatus -eq 'Enabled' }

5. Query Directory Role Memberships:

$roles = Get-MgDirectoryRole | ForEach-Object { Get-MgDirectoryRoleMember -DirectoryRoleId $_.Id }

6. Update Microsoft Graph Modules:

Update-Module Microsoft.Graph -Force

7. Check Microsoft Graph Module Version:

Get-InstalledModule -Name Microsoft.Graph.Identity.DirectoryManagement | Select Version

8. Filter Non-User Objects in Role Memberships:

$users = $roles | Where-Object { $_.AdditionalProperties['@odata.type'] -eq '#microsoft.graph.user' }

9. Export Data to CSV for Long-Term Analytics:

$licenses | Export-Csv -Path "C:\Reports\LicenseUsage.csv" -NoTypeInformation

10. Automate Monthly Reports with Task Scheduler:

Create a scheduled task to run the script monthly:

$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-File C:\Scripts\M365LicenseUtilization.ps1"
$trigger = New-ScheduledTaskTrigger -Monthly -At 9am
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "MonthlyLicenseReport"

What Undercode Say:

This script is a powerful tool for IT administrators managing Microsoft 365 licenses. By automating the generation of license utilization reports, it saves time and provides actionable insights. The integration of PowerShell with Microsoft Graph API allows for extensive customization and automation. For long-term analytics, consider storing monthly usage records in a database or using Power Automate to ensure data retention. Always keep your Microsoft Graph modules updated to avoid compatibility issues. For further reading, check out the Microsoft Graph API Documentation.

Related Commands:

  • Linux Command to Check Disk Space:
    df -h
    

  • Windows Command to Check System Information:

    systeminfo
    

  • Linux Command to Monitor Network Traffic:

    sudo tcpdump -i eth0
    

  • Windows Command to List Installed Programs:

    wmic product get name,version
    

  • Linux Command to Check Running Processes:

    top
    

  • Windows Command to Check Active Connections:

    netstat -an
    

  • Linux Command to Check Open Ports:

    sudo netstat -tuln
    

  • Windows Command to Flush DNS Cache:

    ipconfig /flushdns
    

  • Linux Command to Check CPU Usage:

    mpstat
    

  • Windows Command to Check Event Logs:

    wevtutil qe System /f:text
    

These commands and scripts are essential for IT professionals managing Microsoft 365 environments and other IT infrastructures.

References:

Reported By: Danielbradley2 Microsoft – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

Whatsapp
TelegramFeatured Image