Viewing Office 365 Licensing Information for Multiple Users

 

Summary: Use Windows PowerShell to Manage Office 365 using Windows PowerShell cmdlets, scripts, and batch processes.

Admittedly, Office 365 user licensing can be a little complicated. But that has nothing to do with Office 365; instead, it’s because, well, Office 365 user licensing can be a little complicated. After all, there are different license packs available through Office 365, and users can be assigned as many (or as few) of the individual product licenses as you see fit. Keeping track of all of that isn’t easy, especially in light of the fact that the Office 365 Admin center only allows you to view license details for one user at a time. Would you like a list of all the users who have been assigned a license for Lync Online? Of course you would. But the Admin center can’t readily supply that.

But Windows PowerShell can. Remember the index numbers that we talked about in the article Working with Office 365 User Licenses? If you do, then you might remember that, in our license pack, Lync Online has an index number of 3. That means we can use this admittedly-cryptic looking line of code to return a list of all the users who have been issued a license for Lync Online:

Get-MsolUser | Where-Object {$_.isLicensed -eq $true -and $_.Licenses[0].ServiceStatus[3].ProvisioningStatus -ne "Disabled"}

And yes, it’s definitely a little complicated. But it does return the information you asked it to return:

UserPrincipalName                     DisplayName           isLicensed
-----------------                     -----------           ----------
ZrinkaM@litwareinc.onmicrosoft.com    Zrinka Makovac        True
FabriceC@litwareinc.onmicrosoft.com   Fabrice Canel         True
AnneW@litwareinc.onmicrosoft.com      Anne Wallace          True
AlexD@litwareinc.onmicrosoft.com      Alex Darrow           True

If you prefer, you could also get back a list of all the users who haven’t been issued a license for Lync Online:

Get-MsolUser | Where-Object {$_.isLicensed -eq $true -and $_.Licenses[0].ServiceStatus[3].ProvisioningStatus -ne "Enabled"}

That will bring back a totally different list of users:

UserPrincipalName                     DisplayName           isLicensed
-----------------                     -----------           ----------
BonnieK@litwareinc.onmicrosoft.com    Bonnie Kearney        True
BrianJ@litwareinc.onmicrosoft.com     Brian Johnson         False

But what if we don’t want to know about Lync Online licenses; what if you want to know about SharePoint Online licenses? Well, if you look back at the licensing table, you’ll see that SharePoint Online licenses have an index number of 5. Our previous code example used an index number of 3 (the index number for Lync Online) when we specified the ServiceStatus property:

Get-MsolUser | Where-Object {$_.isLicensed -eq $true -and $_.Licenses[0].ServiceStatus[3].ProvisioningStatus -ne "Disabled"}

To get back SharePoint Online licenses, just replace the 3 with a 5:

Get-MsolUser | Where-Object {$_.isLicensed -eq $true -and $_.Licenses[0].ServiceStatus[5].ProvisioningStatus -ne "Disabled"}

It really is that easy.

For more information, take a look at the article License Users for Office 365 Workloads. Does it take a little bit of effort to master the licensing options available to you using Windows PowerShell? Yes, it does. Is it worth that little bit of effort in order to be able to take advantage of the licensing options available to you using Windows PowerShell? That’s really up to you to decide.

But: yes.

Next: A Quick Note Regarding Positional Parameters and Office 365

See Also

Using Windows Azure Active Directory to Manage Office 365