My colleague and I were running a project of Office 365 with a given THIN timeframe, we’d ran a couple of research looking for scripts to enable the Office 365 Users with the appropriate license and customized to fit into ours and I would like to take this opportunity to share this to those who need help on this as well.

With the given scenario & environment:

  • Running on Azure ADSync & ADFS 3.0
  • All User Objects has been synchronized to the Office 365
  • You manage to export all of the sync users into a CSV format

To do this, launch the Azure Active Directory module for PowerShell:

  1. Connect to the Microsoft Online Services (Connect-MSOLService)
  2. Find out what SKU or Plans that you’re entitled or Subscribed using Get-MSOLAccountSKU. The PowerShell cmdlet should return you with the following format: Tenant:ENTERPRISEPACK
  3. Next, declare the environment variables for Path where the CSV is stored and the type of License queried earlier at Step 2
    $path = “<Drive Letter>:\Filename.csv” (“D:\MSOLE3.csv”)
    $lic = Tenant:ENTERPRISEPACK
  4. Now, you’re ready to assign the licenses with this cmdlet
    Import-Csv $path | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses “$lic”} -Verbose
  5. Once it is done, verify the licenses are correctly assigned:
    Import-CSV $path | Get-MSOLUSer | Out-GridView