Bulk Enable Office 365 License Options

There are a number of online PowerShell resources which describe how to bulk assign an O365 license while enabling only certain service options.  In general, you would define the –DisabledPlans parameter using New-MsolLicenseOptions and assign the license using New-MsolUserLicense.  However, how do you go back and bulk enable a specific service option after the license has been assigned?

Let’s consider the following scenario… you have just completed a mail migration to O365 and all accounts were successfully licensed with only the Exchange option enabled.  Team Sites are now ready and you need to assign the SharePoint and Office Web Apps service for all users.  One option would be to simply enable all the remaining services in the license:

$Options = New-MsolLicenseOptions –AccountSkuId "tenant:ENTERPRISEPACK"

Set-MsolUserLicense –UserPrincipalName [UPN] –LicenseOptions $Options

Notice the absence of –AddLicenses parameter from the Set-MsolUserLicense cmdlet.  Trying to add a license that is already assigned results in an error.  Therefore, we simply enable all the other service options contained within the license.  Another method might be to remove the currently assigned license and re-apply it using the desired service options.  However, there is risk associated with removing a license.  The existing Exchange mailbox could become orphaned and an empty one re-provisioned.  Also, any related O365 service data associated with the user account might be lost.

Now, let’s consider a similar but slightly more complicated scenario. User accounts each have an inconsistent mix of service options enabled; some have SharePoint enabled, some have Lync enabled, and not all have Exchange.  How do you assign the Office subscription (for example) to all accounts?  You can’t blindly enable all remaining options, as this would provide access to services which may not be desired.  Removing the license and re-applying it also proves difficult. The solution is to query each user accounts to determine which service options are currently active or inactive, add the service you would like to enable, and assign the results.  (NOTE: This is written for E3 license, but easily adapted for other SKUs.)

First, we'll create a data set to run against.  I typically prefer using a CSV import file when making bulk changes, but the task could also be run against all licensed accounts:

Import-Csv c:\o365\AssignOption.csv | ForEach {

#Get-MsolUser –All | Where { $_.IsLicensed –eq $true } | ForEach {

$Upn = $_.UserPrincipalName

Let’s initially assume all service options for the user are currently disabled:

$Exchange = "Disabled"; $SharePoint = "Disabled"; $Lync = "Disabled"; $Office = "Disabled"; $WebApps = "Disabled"

We retrieve the assigned license and make note of which options are actually enabled for the user:

(Get-MsolUser -User $Upn).Licenses[0].ServiceStatus | ForEach {

If ($_.ServicePlan.ServiceName -eq "EXCHANGE_S_ENTERPRISE" –and $_.ProvisioningStatus -ne "Disabled" { $Exchange = "Enabled" }

If ($_.ServicePlan.ServiceName -eq "SHAREPOINTENTERPRISE" –and $_.ProvisioningStatus -ne "Disabled") { $SharePoint = "Enabled" }

If ($_.ServicePlan.ServiceName -eq "MCOSTANDARD" –and $_.ProvisioningStatus -ne "Disabled") { $Lync = "Enabled" }

If ($_.ServicePlan.ServiceName -eq "OFFICESUBSCRIPTION" –and $_.ProvisioningStatus –ne "Disabled") { $Office = "Enabled" }

If ($_.ServicePlan.ServiceName -eq "SHAREPOINTWAC" -and $_.ProvisioningStatus -ne "Disabled") { $WebApps = "Enabled" } }

Next, we create an array and populate the variable with the results from the license audit.  In this example, Office is not added as a disabled option since we will be enabling this service for all users:

$DisabledOptions = @()

If ($Exchange -eq "Disabled") { $DisabledOptions += "EXCHANGE_S_ENTERPRISE" }

If ($SharePoint -eq "Disabled") { $DisabledOptions += "SHAREPOINTENTERPRISE" }

If ($Lync -eq "Disabled") { $DisabledOptions += "MCOSTANDARD" }

#If ($Office -eq "Disabled") { $DisabledOptions += "OFFICESUBSCRIPTION" }

If ($WebApps -eq "Disabled") { $DisabledOptions += "SHAREPOINTWAC" }

Now we can create the license option variable which assigns all services except those that were not already enabled:

$LicenseOptions = New-MsolLicenseOptions –AccountSkuId "tenant:ENTERPRISEPACK" –DisabledPlans $DisabledOptions

And finally, we apply the license to the user account:

       Set-MsolUserLicense –User $Upn –LicenseOptions $LicenseOptions

These same concepts can be used in a number of different scenarios for which only certain O365 license options must be bulk enabled.  For a more complex scenario and some advanced license reconciliation concepts, please refer to Bulk Migrate Office 365 Licenses.  RjZ

UPDATE:  I received feedback that this script may not work properly when more than one license or stand-alone SKU is assigned.  Therefore, I have revised it to detect and evaluate the E3 license only, even if other SKUs are assigned.  This is easily changed in the script to look for other SKUs too.  I have also included logic for Yammer.

Enable-LicenseOptions.zip