Export Office 365 User License Report With PowerShell
As an Office 365 Administrator, often you are in the situation to get all licensed users with their assigned licenses and services. Using the O365 admin portal, you can get user’s license information, but you need to click each user to know about their license subscriptions and service status which is a cumbersome task. To manage Office 365 licenses, you can use PowerShell commands. Get-Msoluser will get the details of all Office 365 users and Where condition used to filter out licensed users alone.
Do you think it’s easy? Definitely not! Because we need to consider following things before jumping right away.
- Msol PowerShell module is under deprecation. So, you need to switch to MS Graph PowerShell and the Get-MgUser cmdlet.
- A user can have multiple licenses.
- Each license gives access to a set of services.
- A user might not have access to all services. Some services might be enabled or disabled based on user needs.
- License subscription names are not user-friendly by default.
We have created a PowerShell script that will get you the detailed license usage report covering all the above cases. It reports all licensed users with their country, assigned licenses, services, and its status. So! Let’s jump into the script right away.
Download Script: O365UserLicenseReport
- The script uses MS Graph PowerShell and installs MS Graph PowerShell SDK (if not installed already) upon your confirmation.
- It can be executed with certificate-based authentication (CBA) too.
- Exports Office 365 user license report to CSV file.
- You can choose to either “export license report for all office 365 users” or pass an input file to get license report of specific users alone.
- License Name is shown with its friendly name like ‘Office 365 Enterprise E3’ rather than ‘ENTERPRISEPACK’.
- The script can be executed with MFA enabled account too.
- The script gives 2 output files. One with the detailed report of O365 Licensed users another with the simple details.
Office 365 License Report – Sample Outputs:
Exported report shows list of licensed users and their assigned licenses.
Detailed Office 365 User License Report:
Detailed Office 365 users’ assigned license report contains user’s Display Name, User Principal Name, License Plan, Friendly-name of License Plan, Service Name, Friendly-name of Service, and Service Status.
Simple Office 365 User License Report:
The simple Office 365 user license report contains user’s Display Name, User Principal Name, and Friendly-name of assigned license with their respective services.
Note: As an admin, it’s essential to know when your subscriptions are going to expire or when Microsoft will charge for renewal. If you are not sure about the answer, you can check Office 365 subscription expiry date report.
Office 365 User License Report with MS Graph – Execution Methods:
You can use this script to either export all licensed users or export list of licensed users in Office 365. You can choose any one of the below methods based on your need.
1.Export all Licensed Users in Office 365:
To export all licensed users in Office 365, run the script as follows.
2.Get Office 365 License Report for a Single/List of Office 365 Users:
You can use –UserNamesFile param to get license report of a user from the input list called “UserNamesInput.txt”.
./O365UserLicenseReport.ps1 -UserNamesFile C:/UserNamesInput.txt
The UserNamesFile must follow the format below: UPN separated by new line without header.
3.Execute the Script with Certificate (Scheduler-friendly):
To automate the script execution, you can use certificates for authentication. Depending on your requirements, you can choose to use a certificate authority (CA) or create a self-signed certificate, which is more cost-effective.
The script can be executed with Certificate-based Authentication(CBA) by specifying the TenantId, ClientId, and CertificateThumbprint parameters in the following format:
.\O365UserLicenseReport.ps1 -TenantId <TenantId> -ClientId <ClientId> -CertificateThumbprint <Certthumbprint>
This format can also be used to schedule the PowerShell script as a scheduled task in the Windows Task Scheduler.
However, it’s important to note that before using certificate-based authentication, you must register an app in Azure AD. To register an Azure app and obtain certificates, you can refer to the connect MS Graph with certificate blog, which provides detailed instructions for manual or automated setup depending on your needs.
Get Office 365 License Reports for Free with AdminDroid:
Why AdminDroid is top choice for Microsoft 365 license reporting?
- Schedules and sends reports to email
- Exports data in various formats, such as CSV, HTML, PDF, etc.
- Filters data to generate fine-grained reports
- Visualizes report data to charts/AI generated graphs
- Manages multiple tenants
- User friendly UI
- License and other 100+ Azure AD reports available in Free Edition itself.
AdminDroid offers a free Office 365 license reporting tool that provides detailed license usage reports and smart dashboards. License reports are categorized based on
- Regainable licenses
- Users and Licenses
- Licensed users
- Unlicensed users
- Users with specific subscription
- Users with free subscription
- Users with trial subscription
- User license changes
- License expiry
- Purchased subscription expiring users
- Purchased subscription expired users
- Trial expiring users
- Trial expired users
- Users with suspended subscription
- Subscription usage report
- Expired subscription
- Unused subscription
- Purchased subscription
- Trial subscription
Additionally, AdminDroid Office 365 reporting tool provides 1600+ pre-built reports and 30+ smart visually appealing dashboards to know about your Office 365 environment at a glance. This tool provides reports on Office 365 reporting, auditing, analytics, usage statistics, security & compliance, etc.
I hope export Office 365 license report using PowerShell blog was helpful. If you modify the script and use it for other use cases, then please leave your idea in the comment section and help more admins.