Bulk Enable Office 365 License Options

Bulk Enable Office 365 License Options

  • Comments 11
  • Likes

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 = NewMsolLicenseOptions –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

Attachment: EnableOptions.zip
Comments
  • While you are saying that this is easily adapted to other plans, I am unable to make it work for Microsoft Office 365 Plan A2 for Students. I will be obliged if you can post an script for that plan. Note that we want to disable Exchange Online (Plan 1) for Students license and enable all licenses / components in Microsoft Office 365 Plan A2 for Students. Thanks.

  • Yatin,

    The licensing for Education customers has different SKU/service plan names.  For example, I did this for one of my EDU customers that wanted to take back SharePoint and Lync licensing (leaving them with only Exchange Online):

    $EnabledUsers = Get-MsolUser -All | Where-Object { $_.IsLicensed -eq "TRUE" } | Select-Object UserPrincipalName

    $ServicePlans = Get-MsolAccountSku | Where {$_.SkuPartNumber -eq "STANDARDWOFFPACK_FACULTY"}

    $OnlyExchangeOnline = New-MsolLicenseOptions -AccountSkuId tenant:STANDARDWOFFPACK_FACULTY -DisabledPlans SHAREPOINTWAC_EDU,SHAREPOINTSTANDARD_EDU,MCOSTANDARD

    ForEach ($line in $EnabledUsers) {

           Write-Host $Line.UserPrincipalName

           Set-MsolUserLicense -UserPrincipalName $Line.UserPrincipalName -LicenseOptions $OnlyExchangeOnline }

    You'll have to get a list of what the service plans the students are currently licensed for.  You'll probably need to use the -RemoveLicense and -AddLicense parameters in the same cmdlet to preserve their existing mailboxes if you need to maintain that data.

  • Hello,

    There is the possibility of the script to generate a log file with the name of each user and each user operation was successful or not?

    I thank you!

  • To easily generate a log file each time you run the script, you just have to insert the Start-Transcript cmdlet at the beginning of the script and then Stop-Transcript at the end.

    This will automatically create a log file containing the script output on your Documents folder.

  • Great - I've been looking for ages for how to enable the LYNC feature for users who already have a licence - and your article is precisely it EXCEPT a minor misprint . . .

    NewMsolLicenseOptions should have a dash in it

    New-MsolLicenseOptions.

    Thanks, Bob

  • Great info RJZ

  • Very nice article! Thank you for the help!

  • Excellent! Saved me a lot of time

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment