Contents

Office 365 - Assigning licenses from powershell

Contents

When you add new users to your domain it is useful to be able to assign licenses using PowerShell to help automate administrating the domain.

First ensure you have downloaded and installed the AdministrationConfig tool from here

Open Powershell and run the following commands to connect to 365, enter your credentials when prompted.

Import-Module MSOnline
$credential = get-credential
Connect-MsolService -Credential $credential

Ensure the user’s location is set before you assign licenses, replace the email address with the one for the user you are updating. Set the location code to your location, the example shows the GB code for Great Britain.

Set-MsolUser -UserPrincipalName user@yourdomain.com -UsageLocation GB

View a list of all of the available licenses and how many remain unassigned.

Get-MsolAccountSku

You can add or remove licenses as required. The following example removes an essentials license and adds a premium license to the user.

Set-MsolUserLicense -UserPrincipalName user@yourdomain.com -RemoveLicenses yourdomain:O365_BUSINESS_ESSENTIALS
Set-MsolUserLicense -UserPrincipalName user@yourdomain.com -AddLicenses yourdomain:O365_BUSINESS_PREMIUM