Reporting on Microsoft 365 Licensing using PowerShell – Part 1

Doctor Scripto

Summary: Will Martin discusses how to report on Microsoft 365 licensing in the cloud.

Hello everyone, Doctor Scripto here today to introduce you to a good friend of mine. Will Martin is a PFE in Messaging here at Microsoft and he wanted to share a wonderful solution he found on reporting on Microsoft 365 licensing with PowerShell.

Will my friend, the Blog is now in your most capable hands!

Thanks for the introduction Doctor Scripto!

I came across an interesting problem recently. I was asked by my large Office 365 customer if I could give them a script that would output all their user account licensing data from their Office 365 tenant. I assured them this would be relatively simple, considering I’d done much worse things with PowerShell. But of course, I ran into problems early on. (By the way, I’m not going to tell you how to get into Office 365 PowerShell. We’re going to assume you are bright enough to handle that already.)

So, back to the subject at hand: You see, first and foremost, I had to consider that not every user in this customer’s (or most customer’s) Office 365 tenant was going to have the same licensing – one might have the Enterprise Premium Exchange license and another then Enterprise Pack Exchange license. The data I recovered had to take this into account. So, using a demo tenant (from http://demos.microsoft.com), I started figuring out how to pull user licensing information. The obvious command for this appeared to be Get-MsolUser. After creating an unlicensed user account, I ran the command and got the following results:

Note that throughout this document, the commands may be wrapped – this is due to the size of the PowerShell window – there are not new-lines within the commands. From our first command, we can obviously see that the user exists and has no license. Now, let’s see what licenses are available in the tenant. For that, we’ll use the Get-MsolAccountSku. Here’s what this command returned:

As you can see, the enterprise premium SKU has no units available, so we’ll use the Enterprise Pack for licensing our new user. Now let’s get the details of this SKU and see what all it entails. Using this same command, we’ll limit it to the SKU in question with a filter, then see what the ServiceStatus of it is – or rather what the SKU’s available applications ServiceStatus are. For that, we run the following command:

We can see that SharePoint, Teams, Skype, Exchange and various other Office 365 tools are available in this SKU (those marked as “Success” in the above listing). Now, we’ll want to give this user some of these, but not all of them. We’ll grant them licenses in the GUI. (We won’t show that here – if you need to know how to license a user, you may not want to be reading this just yet.) And once we have it licensed, the Get-MsolUser command shows it as licensed:

Well, that’s certainly useful – we now know that the user is licensed. But for what? Looks like we’re going to need a bit more information. At this point, we’re going to pop the user info into a variable so we can work with it a bit more readily:

Now we can refer to our user as $DemoUser. What can we see from this user, then? Well, let’s see what anything with “license” gives us:

Well, that’s certainly better – and look – there’s our Enterprise Pack, along with our demo tenant name: {M365x237466:ENTERPRISEPACK}. Note that this is in squiggle braces – this means it could hold more than one license pack. And indeed, if we add other license packs to this user, we will see them also listed in the same field:

But we don’t want to muddy the waters just yet – we’ll remove the extra licenses and go back to our $DemoUser variable to see what else we can learn. Let’s look a bit more closely at the Licenses field:

OK, so we’ve got a bit more information here – we’ve got some “ExtensionData”, whatever that might be, an AccountSku and its relevant AccountSkuId (which matches the license field we saw previously), and “ServiceStatus”. Let’s see what our account’s ServiceStatus is:

Bingo!! Here we see the service status of each application the user might have been licensed for. Looks like Exchange, SharePoint, Teams, Sway, and a few others show Success, others show some pending statuses (actually, status, but accenting the U, but details …), and the rest showing Disabled. If we look at the licenses we gave the user it shows:

This makes sense – several aren’t enabled, others are.

Come back next Wednesday as we continue on with our discussion of Reporting on Microsoft 365 licenses! .

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Forum. See you tomorrow. Until then, peace.

Your good friend, Doctor Scripto

PowerShell, Doctor Scripto, Will Martin, Microsoft 365, Reporting

 

0 comments

Discussion is closed.

Feedback usabilla icon