Assigning multiple customized plans to an Office 365 user via PowerShell

Another one in the series of “did you know that…”. If you have ever used PowerShell to assign licenses to a user, you might be aware of the method to disable particular service, say assign the E3 plan with Exchange Online disabled. In a nutshell, one has to use the following two cmdlets:

PS C:\> $l1 = New-MsolLicenseOptions -AccountSkuId tenant:ENTERPRISEPACK -DisabledPlans EXCHANGE_S_ENTERPRISE

to set the customized plan, followed by

PS C:\> Set-MsolUserLicense -UserPrincipalName -AddLicenses tenant:ENTERPRISEPACK -LicenseOptions $l1

to actually assign the license.

Now, what if you wanted to assign multiple licenses? The -AddLicenses parameter accepts multi-string values, so one can do the following:

PS C:\> Set-MsolUserLicense -UserPrincipalName -AddLicenses tenant:PLANNERSTANDALONE,tenant:ENTERPRISEPACK -LicenseOptions $l1

So we just assigned both the E3 and the Planner standalone licenses, while disabling the Exchange online service at the same time. As the customized plan settings, contained in the $l1 variable, include the information of the license/SKU we are customizing, no conflict will occur. And we can even take it one step further – prepare yet another customized plan (in this case the Planner SKU, with the Planner service disabled), and use the same one-liner to assign both plans. Here’s how it would look like:

PS C:\> $l2 = New-MsolLicenseOptions -AccountSkuId tenant:PLANNERSTANDALONE -DisabledPlans PROJECTWORKMANAGEMENT

to create the second customized plan, followed by

PS C:\> Set-MsolUserLicense -UserPrincipalName -AddLicenses tenant:PLANNERSTANDALONE,tenant:ENTERPRISEPACK -LicenseOptions $l1,$l2

to assign both SKUs with their respective customized options. The end result:

PS C:\> (Get-MsolUser -UserPrincipalName

ServicePlan           ProvisioningStatus
-----------           ------------------
SWAY                  Success
INTUNE_O365           PendingActivation
MCOSTANDARD           Success
SHAREPOINTWAC         PendingInput

where the second instance of the PROJECTWORKMANAGEMENT service is the one we disabled via the $l2 plan settings.

That’s all for today’s tip, hopefully you will find it useful, or just interesting 🙂

This entry was posted in Office 365, PowerShell. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *