Bulk assign custom Office 365 licenses via Powershell

I came up to create this easy script (with a little bit of help) because I wanted to bulk assign users an E3 license but without assigning Exchange Online functionality. The scripts I found on the internet were way to complex or just not working.

You can have several reasons why you do not want to assign every part of the license to a user. In my case mailboxes for this customer would not be migrated to Office 365 for the next months and therefor I don’t want Office 365 to create a mailbox for these users.

The script below should however a little bit being modified to suit your specific tenant. To start you will need to connect Powershell to Office 365 with the cmdlet Connect-MsolService. After this you will need to perform the following cmdlet to retrieve your AccountSKU Get-MsolAccountSku. This is needed because this will identify your tenantname and will show you which license you have to provide in the script.

The output will be something like this. Note that the blogoffice:ENTERPRISEPACK is used in the script twice. ENTERPRISEPACK is the reference for the E3 license. Other SKU’s can be found here http://blogs.technet.com/b/treycarlee/archive/2013/11/01/list-of-powershell-licensing-sku-s-for-office-365.aspx

scr1

If you want to provide more disabled plans you can do so by adding a , in between the plans like this -DisabledPlans @(“EXCHANGE_S_ENTERPRISE”,”SHAREPOINTENTERPRISE”)

Your UsageLocation can be adjusted as well of course to En-Us or something entirely different. Now copy the script (between the lines only) and save it somewhere as script.ps1

———————————————————-

$AccountSkuId = “TENANTNAME:ENTERPRISEPACK”

$UsageLocation = “NL”

$LicenseOptions = New-MsolLicenseOptions -AccountSkuId TENANTNAME:ENTERPRISEPACK -DisabledPlans @(“EXCHANGE_S_ENTERPRISE”)

$Users = Get-Content c:\temp\users.txt
foreach ($user in $users)
{
$user

#New-MsolUserLicense -UserPrincipalName $user
Set-MsolUserLicense -UserPrincipalName $user -AddLicenses $AccountSkuId
sleep -Seconds 5
Set-MsolUserLicense -UserPrincipalName $user -LicenseOptions $licenseoptions
Set-MsolUser -UserPrincipalName $user -UsageLocation $UsageLocation
}

———————————————————-

The next step is to make sure you have your users UPN’s in a txt file each one on the next line. In the script above I have users.txt saved in the temp folder on the c drive. Now just navigate to your c:\temp folder from Powershell and run the script by doing .\script.ps1

Now your users will be licensed one by one with small pauses of 5 seconds.

scr2

 

Share this blog!

4 thoughts on “Bulk assign custom Office 365 licenses via Powershell”

  1. Hi

    Good post. Out of interest, for a given user is there a minimum plan then can have.
    For example for a Business premium user, could I remove all to avoid monthly charges
    “EXCHANGE_S_STANDARD” ,”SWAY”,”INTUNE_O365″,”SHAREPOINTWAC”,”OFFICE_BUSINESS” ,”YAMMER_ENTERPRISE”, “MCOSTANDARD”,”SHAREPOINTSTANDARD”`

    1. Hi Daniel,

      Do you mean removing part of the assigned services of the license to save costs? In that case that is not possible unfortunately. You are paying for the complete license no matter what services you assign to a user. However if you want a user only to have let’s say a mailbox without all other services you need to buy an Exchange Online plan. Hope this answers your question, if not just let me know 🙂

  2. Thanks for the article Dennis, how do we manage the bulk assignment limited to only certain features while keeping SWAY, YAMMER & TEAMS disabled?

    Thanks
    Mani

Leave a Reply

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