Assign license to office 365 users via powershell

This post is about how to assign license to office 365 users via powershell. We will need a csv with the required users.

Open the Windows Azure Active Directory Module and run:

Import-Module MsOnline
Connect-MsolService
Get-MsolAccountSku <# get the list of the license options #>
$license = New-MsolLicenseOptions -AccountSkuId xxxx:XXXXXXXXX_XXXXXXXX <#here we can specify more license options #>
Import-Csv C:list.csv | foreach { Get-MsolUser -UserPrincipalName $_.UPN | Set-MsolUser -UsageLocation XX } <# where XX is the country ID #>
Import-Csv C:list.csv | foreach { Get-MsolUser -UserPrincipalName $_.UPN | Set-MsolUserLicense -AddLicenses "xxxx:XXXXXXXXX_XXXXXXXX" -LicenseOptions $license }

 

 

Share

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.