Working with Office 365 User Licenses
Summary: Use Windows PowerShell to Manage Office 365 using Windows PowerShell cmdlets, scripts, and batch processes.
As we noted previously, there are plenty of things you can do with the Azure cmdlets; for example, this command returns information about the number of Office 365 licenses you have, as well as the number of licenses you have yet to distribute:
Get-MsolAccountSku
That’s going to return data similar to this:
AccountSkuId ActiveUnits WarningUnits ConsumedUnits
------------ ----------- ------------ ------------
litwareinc:ENTERPRISEPACK 25 0 25
In our sample data, the litwareinc domain has been issued 25 licenses (ActiveUnits) and all 25 licenses are currently assigned to users (ConsumedUnits).
That’s good. Of course, even better would be the ability to see the licenses which have been assigned to an individual user. Without explaining all the details, here’s how we can find the licenses currently assigned to Ken Myer:
Get-MsolUser -UserPrincipalName "kenmyer@litwareinc.onmicrosoft.com" | Select-Object -ExpandProperty Licenses | Select-Object -ExpandProperty ServiceStatus
OK, we’ll offer a cursory explanation, because this is definitely a more-complicated command. In this command, we first use Get-MsolUser to return information for the user kenmyer@litwareinc.onmicrosoft.com. We then pipe that information to the Select-Object cmdlet, and use the ExpandProperty parameter to “expand” the Licenses property. We need to do that because Licenses is a multi-valued property; that means it contains multiple values (in this case, multiple licenses), and we want to make sure we are working with all the licenses. We then pipe the license information to Select-Object and expand the ServiceStatus property in order to get detailed information about each individual license.
Note
Take a look at this article on multi-property values if that cursory explanation proved to be no explanation at all.
When all is said and done, we should get back something similar to this:
ServicePlan ProvisioningStatus
----------- ------------------
YAMMER_ENTERPRISE None
RMS_S_ENTERPRISE Success
OFFICESUBSCRIPTION Success
MCOSTANDARD Success
SHAREPOINTWAC Success
SHAREPOINTENTERPRISE Success
EXCHANGE_S_ENTERPRISE Success
Admittedly, it might not be obvious at first glance what’s going on here. Fortunately, it’s not as obtuse as it might seem. The ServicePlan property contains a collection of licenses (the licenses available in your organization depend on the Office 365 plan that you purchased). The values in our ServicePlan property equate to the following:
Index Number | Service Plan | Product |
---|---|---|
0 |
YAMMER_ENTERPRISE |
Yammer |
1 |
RMS_S_ENTERPRISE |
Windows Azure Active Directory |
2 |
OFFICESUBSCRIPTION |
Office Professional Plus |
3 |
MCOSTANDARD |
Lync |
4 |
SHAREPOINTWAC |
Office Web Apps |
5 |
SHAREPOINTNETERPRISE |
SharePoint |
6 |
EXCHANGE_S_ENTERPRISE |
exchange |
In turn, the ProvisioningStatus property tells us whether the license has been assigned or not:
None means that no license has ever been assigned.
Success means that the license is assigned.
Disabled means that the license was assigned but has since been disabled.
As you can see, Ken Myer has been assigned all the available licenses except for Yammer.
Note
What’s the Index Number in the preceding table? The index number is another identifier for the service plan. Based on good old-fashioned computer programming, the first item in a collection like this is assigned index number 0. Thus YAMMER_ENTERPRISE has the index number 0. The second item in the collection is assigned index number 1, the third item is assigned index number 2, and so on. As we’ll see in a moment, these numbers can be used to do things like show you all the users who have a Yammer license, or all the users who don’t have a Yammer license.
So can we change these licensing assignments; for example, can we disable Ken’s ability to use Exchange and Lync Online? You bet we can. Again, we won’t bother to explain how this all works; that’s a topic for another day. However, in Office 365 you can manage licenses (in part anyway) by indicating which licenses should be disabled. That’s done by creating a new licensing options object, like this one:
$disabledLicenses = New-MsolLicenseOptions -AccountSkuId "litwareinc:ENTERPRISEPACK" -DisabledPlans "MCOSTANDARD","EXCHANGE_S_ENTERPRISE"
What we’ve done here is simply say that, for the litwareinc domain (which has purchased the Enterprise licensing pack) we want to disable two plans: Lync (MCOSTANDARD) and Exchange (EXCHANGE_S_ENTERPRISE). Note that this command, by itself, doesn’t disable these licenses for any user. Instead, it creates a generic user license in which both Lync and Exchange have been disabled. We can then take that generic user license and assign it to an actual person:
Set-MsolUserLicense -UserPrincipalName "kenmyer@litwareinc.onmicrosoft.com" -LicenseOptions $disabledLicenses
If we run that command and then take a second look at Ken’s user licenses we should see something that looks like this:
ServicePlan ProvisioningStatus
----------- ------------------
YAMMER_ENTERPRISE None
RMS_S_ENTERPRISE Success
OFFICESUBSCRIPTION Success
MCOSTANDARD Disabled
SHAREPOINTWAC Success
SHAREPOINTENTERPRISE Success
EXCHANGE_S_ENTERPRISE Disabled
Voila! Both Exchange and Lync Online have been disabled.
Viewing Office 365 Licensing Information for Multiple Users