How To Assign Licenses to Office 365 Users the Easy Way

There have been written a lot of posts about assigning licenses to Office 365 through PowerShell, so why another? Two reasons: first, on december 1st, Student Advantage will be released and a lot of Education Institutes still don’t feel comfortable enough around Office 365 and PowerShell. Second, a lot of scripts don’t give you that additional edge that these script are going to give you.

These scripts are based upon the following technet article:

But I’ve noticed that while I was trying these scripts there were some inaccuracies in the text and in the scripts. They’ve also made some assumptions that were a little bit strange to me while designing the scripts.


I want all my students to receive an A2 License.  The Students are defined in the Active Directory by the value Student in the Attribute EmployeeType. The correct License for that user is stored in extensionAttribute14.

So how does this work:

Let’s start with the prerequisites:

  • Make sure you are able to execute PowerShell Cmdlets -check your ExecutionPolicy
  • Make sure the Windows Azure Active Directory Cmdlets are installed -get them from your Office365 Portal, if not.
  • Download the scripts here

Preparation Phase

  • Unzip the scripts on a machine that has access to the Active Directory and has all the prerequisites in check
  • You should have 3 tmp files, AssignLicense.tmp, Get-LicensingInputFromAD.tmp and Get-MSOLUserLicensingReport.tmp
  • You should have 1 ps1 file, SetupScript.ps1


Setup Phase

  • Run SetupScript.ps1. This script will create the necessary ps1 that will execute all the steps to Retrieve the license info from AD, Assign the correct Licenses and check if they are set correctly.
  • Enter all the values correctly and the scripts and folders are being generated.


In the file LicenseInformation you’ll get all the different SKU’s available on the tenant.

Adjusting your AD. If you want this scenario for Student Advantage, change the value to OFFICESUBSCRIPTION


Now we can start by Getting data from AD and assign licenses.

Step 1: Get UPN & License information from  AD by running Get-LicensingInputFromAD.ps1. This creates me a csv that I will use to assign user licenses.

Step 2: Assign Licenses by running AssignLicense.ps1. This scripts will check and set all the User Licenses where necessary from the csv stored in the queuedLicense directory. When everything is executed the csv’s are moved to the completedImportFiles directory.

If something goes wrong you’ll find information in the Logs directory or in the Event Viewer


If you want an overview of all the licenses of your users.

Step 3: Report Licenses by running Get-MSOLUserLicenseReport.ps1 which creates a csv with an overview.

I will publish the scripts shortly where you can add multiple licenses at once. Contact me for more information

One thought on “How To Assign Licenses to Office 365 Users the Easy Way

Leave a Reply