Office 365: Script to get detailed report of assigned licenses

BLOG UPDATE: April 1st 2021

Hi everyone. I wrote this blog post many years ago, and throughout the years this has been a blockbuster in terms of visits. Thank you for that.

I think that highlights the growing need companies have, to assess their Microsoft 365 portfolio. That of course comes from a gap in the native portal and the native reporting capabilities.

I decided to update this blog post and let you all know about the BitTitan Voleer IT Automation Toolbox. Those who know me, know that I work for BitTitan, but this is not a “sponsored” blog post. You can register for free and it literally takes you 5 seconds to fill in the below, which is all the information you need to give, to register and trial it for 30 days.


Once you register you can login and either search in the library for “Microsoft 365 License Usage And Optimization Assessment” or go directly to it, by clicking here.

You can then follow these simple steps to execute the assessment:

  1. Read the instructions and click on “Launch” on the right hand side, once you select the Workspace (Sandbox is the default)
  2. Authorize Microsoft Graph access to your tenant, by clicking the available links and entering the code provided. Click “Validate” when done.
  3. In “Configure” you can configure filters to assess just part of your Organization. The filters can be done by dropdowns, string or using User Principal Names. Common filters you can use include country, account log in state or Department, amongst others. Leave blank to assess the entire tenant.
  4. Also in “Configure” you can select to email the report from a Voleer email address, or from one that you would put username and password for. You then select to which address is the report being sent to and password protect it.
  5. Once all of the above is completed, click “Execute”

Once the execution is complete you will get an email, with an attached CSV with multiple tabs, with all the information you need. See below an example of the assessment Dashboard.

MicrosoftTeams-image (3)

You can save the template configuration, to make future executions easier and you can also schedule it. Those are 2 huge benefits that add to the fact that you have the awesome feature of filtering the assessment (i.e assess licensing for login disabled users only). Top that with not having to handle PowerShell scripting and I think you have enough reasons to go check Voleer out.

Voleer has many other templates in the library, that you can check out and run during your free trial.

Any questions let me know and, if you want to run it the “old way”, keep reading. I have the PowerShell “one liners” below that will help you create the reports of your licensed users.


It’s very common to see Office 365 administrators asking in the community “How can I get a detailed report of the licenses i have assigned on Office 365?

Well it will depend on how detailed you want the report. I’ll detail here two solutions.

1 – Get a report of all licensed users and the AccountSKUId name

To run this report you need to open the Windows Azure Active Directory Module for Windows Powershell, and connect to Office 365. Once connected run the following cmdlet:

Get-MSOLUser -All | select userprincipalname,islicensed,{$_.Licenses.AccountSkuId}| Export-CSV c:\userlist.csv -NoTypeInformation

The above command lists ALL users and not just the ones that have a license. See the output CSV file below. There are ways of filtering the output (i.e export only licensed users), but i will keep this post simple. Let me know if you need something more elaborated.


2 – Get a detailed report of the licenses enabled for each user

One of the other requirements, is to know in detail, how many licenses per product do you have enabled, and which users have that license. If you want a detailed list with the users that have Lync Online, Exchange Online, Office Pro Plus (just to give three examples), or any other product that you have on your subscription, enabled or disabled, all you need to do is use the “Export a Licence reconciliation report from Office 365 using Powershell” script available on the Microsoft Gallery.

Again to run this report you need to open the Windows Azure Active Directory Module for Windows Powershell, and connect to Office 365.

Once connected to Office 365 browse into the directory where you saved the script, and run it.


The script will prompt you for the Office 365 administrator credentials, and run against all licensed users. By default the script creates a file named “Office_365_Licenses.csv” that will be created on the same directory where the script is. If you want, you can change it by editing the script. There’s also some other things you can change on the script, such as export all users and not just the licensed users, or use the existing credentials cached on your powershell session, instead of prompting you for credentials each time you run it. But again I will keep it simple for now, and if you want to change something on how the script works, let me know.

Now let’s have a look at the detailed output of the script.


Let’s now take the user Antonio Vargas as an example. He has all licenses assigned. Let’s see the view from the portal.


As you can see the Yammer licenses are assigned by default (hence the “PendingInput” state on the property exported to csv), and all other licenses are assigned, which matches with the success property on the csv. Now below let’s have a look at the user Calvin, which only has the Exchange Online license enabled (and the Yammer by default). All the other licenses are disabled.


Again when looking to the licenses that the user Calvin has assigned, via the Office 365 portal, it matches the csv file.

If you want, and because usually the output you will get is a very large csv file, you can use filtering at the csv level to get smaller lists depending on the license type you want the report on.

Any questions let me know, and happy reporting! 🙂


27 thoughts on “Office 365: Script to get detailed report of assigned licenses

  1. Yunar September 28, 2015 / 5:34 am

    I run script: Get-MSOLUser -All | select userprincipalname,islicensed,{$_.Licenses.AccountSkuId}| Export-CSV c:\userlist.csv -NoTypeInformation

    The $_.Licenses.AccountSkuId column is empty, UserPrincipalName IsLicensed columns are OK.
    Please advise.

  2. AMVargas September 30, 2015 / 11:49 pm

    Hi Yunar, what value do you have on the IsLicensed column? If its false then the $_.Licenses.AccountSkuID should be empty, as the user does not have any license assigned.

  3. carloswalker906525629 February 24, 2016 / 5:00 pm

    I downloaded the PowerSHell script mentioned in section 2, but it doesn’t return correct values. We have 129 E3 plans, 4 Visio, and 10 Project… it listed only 119 E3 users, 2 Visio and 8 Project… Seems to skip users once it has found 1 package, without listing what the other packages the user has licensed.

    • carloswalker906525629 February 24, 2016 / 5:13 pm

      I ran the script in section 1, and imagine what is happening is that when the script in section 2 finds a case like this: “ TRUE tenant:ENTERPRISEPACK tenant:PROJECTCLIENT” it only lists the 1st package licensed, not both.

      • Peter March 3, 2016 / 12:54 pm

        What is the Solution then ?

  4. AMVargas March 9, 2016 / 12:36 am

    Hi Carlos, sorry to read you had those issues. In fact the script wasn’t designed for that number of plans. Did you managed to get an alternative working? If not I might try and find some time to look at the script and apply some changes. Thanks for the feedback

  5. Ville March 22, 2016 / 8:07 am

    Hello Amvargas,

    I am getting same results as Carlos, have you had time to check on the script?

    Best regards Ville

  6. Davidk May 12, 2016 / 12:38 am

    HI This report is great however I have a question, due to my company having limited licenses and being very frugal on buying new ones we have to swap licenses for users who leave and don’t require them, is it possible in the above report to include a column of the date and time the license was assigned and if possible by which admin user.

    • David Hole September 18, 2017 / 1:12 pm

      Hi David, did you manage to get a report like that, i’m looking for something similar.

  7. DFS July 6, 2016 / 4:51 pm


    Do you have a script that will remove licenses(ex:I have E3 licenses assigned but want to keep Exchange Online (Plan 2) only. I have hundreds of users and I don’t want to do it manually in the portal.

    Thank you!

    • scar July 27, 2016 / 10:20 am

      DFS: you can use Set-MsolUserLicense -userprincipalname “” -RemoveLicenses “licensename” to remove a license I guess

      • Steve Rackham December 15, 2016 / 12:58 am

        Hi DFS,
        You can do this by disabling portions of the license. This is done with a combination of New-MSOLLicenseOptions and Set-MSOLUserLicenseOptions.

        Get all the service plans with this –
        Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq “ENTERPRISEPACK”} | ForEach-Object {$_.ServiceStatus}

        Then disable all bar the EXCHANGE_S_ENTERPRISE
        Set the license options,
        $LO = New-MsolLicenseOptions `
        -AccountSkuId “Fakey:ENTERPRISEPACK” `

        then apply,

        # Set the MSOL User License.
        Set-MsolUserLicense `
        -UserPrincipalName fakey.mcfakerson@fakey.domain `
        -AddLicenses “Fakey:ENTERPRISEPACK”,”Fakey:EMS” `
        -LicenseOptions $LO

        and check,

        (Get-MsolUser -UserPrincipalName fakey.mcfakerson@fakey.domain).Licenses.ServiceStatus

        Hope this helps,

  8. scar July 27, 2016 / 10:19 am

    DFS: you can use Set-MsolUserLicense -userprincipalname “” -RemoveLicenses “licensename” to remove a license I guess

  9. NIL August 19, 2016 / 12:56 pm

    From script 2, I need a report to extract E1 users for whom only OneDrive is enabled.
    Can you please help me with this.

    • Filip March 31, 2017 / 8:53 am

      Hi Nil, have you found an answer to your question ? I am interested too.

  10. Brandon November 3, 2016 / 3:26 pm

    I have been asked to pull the following information out of our O365 account. User ID, Email Address, Status “Licensed” and where or not the account is active. I believe the MailBox Type will tell me this, User = Active, User (Archive) = Disabled.

    I am using the following but not only getting data on UserPrincipalName.

    Get-MsolUser -maxresults 5000 | Where-Object {$_.isLicensed -eq “Ture”} | Select-Object UserPrincipalName,DisplayName,MailBoxType

    Any suggestions?

  11. Donna Smith February 1, 2017 / 11:03 am

    Is it possible to create a script to check which accounts are licensed….but it reads a list of users from csv file and checks these then provides the output.
    I have several different s/s which before removing accounts i need a script to tell me which accounts are on prem and which are 365 licensed

    • AMVargas February 2, 2017 / 12:58 am

      Hi Donna, so you want the script to read from a pre defined list of users you have on a Csv and list if those are licenses or not?

  12. ValSal June 7, 2017 / 6:36 pm

    Hi Guys – I am working to created PowerShell script to go and read UPN form an csv file and add new users on that list to a security group in O365 so they get EMS license. My issue is that csv file will have already proceeded users and I need my script to skip all processed users and move only new entries. Any ideas?

  13. Ken June 8, 2017 / 5:58 am

    I have some users on W7 and some on W10 is there a way to show which users are on which OS

    • AMVargas July 15, 2017 / 5:32 pm

      Ken you can use the Bittitan Device Management Agent, that had a module called HealthCheck for Office 365. That will provide you a desktop assessment and it’s a module that does not require a license

  14. A July 14, 2017 / 7:02 pm

    Hello, Is there a way to see the time a user was unlicensed.?

    • AMVargas July 15, 2017 / 5:34 pm

      I don’t think so but maybe via the PowerShell you can find something. Unlicensing a user removes the mailbox, so I recommend doing a Get-mailbox on disconnected mailboxes and getting all the info with a |fl to check if any info there indicates the date of disconnect

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s