Updated 4 weeks ago

Export Microsoft 365 License Cost Report Using PowerShell

by Praba

7 min read

No Comments

Microsoft 365 offers a vast array of plans and licenses, making it easy to find the perfect fit for your business needs. But with that flexibility comes complexity. Managing Microsoft 365 licenses and the cost spent on all those licenses can lead to confusion and can be a challenge. By using native methods, admins can obtain the list of licenses assigned to users, but not the cost details.

But why do admins need Microsoft 365 license cost report?

  • Knowing exactly how much is being spent on licenses empowers admins to identify areas for saving. This can involve finding users who aren’t utilizing their assigned licenses or who could be on a lower tier plan.
  • Microsoft 365 license cost report gives admins a clear picture of which licenses are assigned to whom. This allows them to ensure users have the appropriate licenses for their needs and identify any inactive users who still have licenses assigned.
  • By understanding current license costs and usage trends, admins can create more accurate budget plans and anticipate future spending needs.

Overall, Microsoft 365 license cost reports empower admins to make data-driven decisions about license management, leading to cost savings, improved budgeting, and better overall license utilization.

To ease admins’ work in calculating license costs, we have crafted a PowerShell script to generate Microsoft 365 License Cost Report. It’s a game-changer for organizations looking to optimize their M365 investment. So, let’s jump into the script right away!

Download Script: M365LicenseCostReport.zip

Script Highlights:

  • This script allows you to generate nicely formatted 2 CSV files of users’ license cost report and license usage & cost report in the organization.
  • Helps to generate license cost report for inactive users.
  • Results can be filtered to lists cost spent on never logged in users only.
  • Exports disabled users’ license costs alone.
  • Exports the cost of licenses for external users exclusively.
  • Identify the overlapping Licenses assigned to users.
  • The script uses MS Graph PowerShell and installs MS Graph PowerShell SDK (if not installed already) upon your confirmation.
  • The script can be executed with an MFA enabled account too.
  • The script is schedular-friendly.
  • It can be executed with certificate-based authentication (CBA) too.

Microsoft 365 License Cost Usage Reports – Sample Output

The output will generate two of the following reports.

1. All Microsoft 365 Users License Cost Report:

This script exports Microsoft 365 users’ license usage & cost report with the following attributes:

  • User Principal Name
  • Assigned Licenses
  • Cost
  • Directly Assigned Licenses
  • Licenses Assigned via Groups
  • Is Duplicate License
  • Number of Duplicate Licenses and their Names
  • Account Status
  • Job Title
  • Department
  • Creation Date
  • Last Sign-in Date
  • Inactive Days
  • Last Successful Sign-in Date
  • User Type
  • Usage Location

M365 Users License Cost Report

2. Microsoft 365 Subscription Usage & Cost Report:

This script exports the overall license costs for a Microsoft 365 tenant with the following attributes:

  • License Name
  • Cost
  • Purchased Units
  • Consumed Units
  • Unused Units
  • Purchased Units Cost
  • Consumed Units Cost
  • Unused Unites Cost
  • SkuID

M365 License Usage & Cost Report

Microsoft 365 License Cost and Usage Report – Script Execution

  1. Download the script.
  2. Start the Windows PowerShell.
  3. Select any of the methods provided to execute the script.

Method 1: You can run the script with MFA and non-MFA accounts

The example provided enables you to export Microsoft 365 license usage & cost reports, covering both the individual users’ license costs and the overall license usage for a Microsoft 365 tenant.

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 Microsoft 365 license expiry date report.

Method 2: You also have the option to run the script using certificate-based authentication, which is schedular-friendly. When you want to run the script attended, you can choose this method.

To use certificates, you must register the app in Microsoft Entra and connect to MS Graph using certificate.

Note: Depending on your requirements, you can create a self-signed certificate.

Get the Most Out of the Microsoft 365 License Cost Report

The script offers flexible filtering options to suit your needs, making it easy to analyze different cost-related situations, including:

Export Users’ License Cost Report in Microsoft 365

Keeping track of Microsoft 365 users’ licenses along with cost helps in optimizing license allocation, reducing unnecessary expenditure, and ensuring compliance with licensing agreements.

To export a report on the cost of users’ assigned licenses in Microsoft 365, run the script as follows.

If you want to specify a particular currency for the report, you can do so by passing the -Currency parameter along with its respective symbol to the script. For instance, if you prefer the report in US dollars, you can execute the script as follows:

Note: By running this script, you can also find the duplicate licenses assigned to a user. Sometimes, users may end up with duplicate licenses if they receive the same license using different user license assignment paths. In such cases, this report is helpful to identify and remove duplicate licenses.

Get Microsoft 365 License Cost Report for Specific Users

For organizations managing various projects or departments, generating license cost reports for targeted user lists facilitates a more detailed analysis of license usage. This can be accomplished by using a CSV file as input to generate a license cost report for the specified users. Please note that the input should be passed as User IDs; UPNs are not supported.

Use the -UserCsvPath parameter to pass the CSV file and retrieve license cost reports for users from the input list. For example,

The input file must follow the format below:

Microsoft 365 License Cost Report

Find the Cost Spent on Microsoft 365 Inactive Users

By identifying users who haven’t logged in for a long time, admins can mitigate risks by revoking unused licenses and improving security. To identify the money spent on Microsoft 365 inactive users, run the script and specify the number of inactive days using the –InactiveDays parameter.

The exported report contains a list of licensed users in Microsoft 365 who have been inactive for 90 days. Additionally, you have the flexibility to generate an inactive Microsoft 365 licensed users report, whether it’s for 30 days, 180 days, or any other specified period.

Track Microsoft 365 Cost Report for Never-Logged-In Users

Never-logged-in users with assigned licenses represent wasted resources. Identify them to reclaim and reassign those licenses to active users. It’s simple yet one of the powerful ways to optimize Microsoft 365 license usage.

To export the never-logged-in user report, run the script with –NeverLoggedInUsersOnly switch. Using this report, you can manage licenses assigned to users who have never accessed their accounts.

Regular review of group-based license assignments also helps in identifying inactive users who no longer require licenses.

Calculate License Costs for Sign-in Enabled/Disabled Users

In many organizations, disabling user accounts is a standard practice in Microsoft 365 employee offboarding to maintain security. To get the license cost report for sign-in disabled users, run the script along with the –DisabledUsersOnly switch parameter. Disabled users cannot sign in or use the licensed services associated with their account.

Likewise, to find the license cost of sign-in enabled users, run the script along with the –EnabledUserOnly switch parameter.

The resulting report will display licenses assigned to users whose accounts are enabled.

Evaluate Costs on External Users with License Assigned

Sometimes, external users might be assigned licenses they don’t actively use. Regularly monitoring license assignments helps identify such cases. By reclaiming those unused licenses, admins can reduce unnecessary licensing costs. To check the license cost spent on external users, execute the script along with the –ExternalUsersOnly switch parameter.

You can further refine the results by specifying -InactiveDays parameter, which will filter the report to show only external users who haven’t been active in the past 90 days.

By doing so, admins can ensure they are only paying for licenses that are actively used.

Audit Financial Impact on Overlapping Licenses in Microsoft 365

Overlapping licenses can result in redundancy, so monitoring and optimizing license distribution is essential to ensure users receive the correct access without complications. So, admins need to track Microsoft 365 users with overlapping licenses, especially those assigned via group memberships, to ensure efficient license management.

To list the Microsoft 365 licensed users with overlapping licenses, include –LicenseOverlapingUsersOnly switch while running the script.

Schedule Microsoft 365 License Cost Report

Admins can use the task schedular to run the PowerShell script automatically at scheduled times. They can set it up to use certificate-based authentication, so it runs smoothly without needing any input from users. This way, admins can generate Microsoft 365 license cost report regularly without hassle.

Take Charge of Microsoft 365 Licenses: AdminDroid’s No-Cost Reporting Solution

AdminDroid offers a free Office 365 license reporting tool that provides detailed license usage reports and smart dashboards. This tool provides 120+ reports and dashboards on user activities, passwords, group actions, licenses, and subscriptions. License reports are categorized based on

  • 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
    • Subscription usage report
    • Expired subscription
    • Unused subscription
    • Purchased subscription
    • Trial subscription

M365 License Cost Report

M365 License Dashboard

Additionally, AdminDroid Office 365 reporting tool provides 1800+ 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.

Download Free Microsoft 365 reporting tool by AdminDroid and transform your Microsoft 365 management experience. to get access to 120+ reports and dashboards on users, groups, group membership details, licenses, user logins, password changes, etc.

I hope export Office 365 license cost report using PowerShell blog was helpful. If you have any further queries, reach out to us through the comment section.

Share article