Set-MsolUserLicense - Manage Office 365 licenses with PowerShell

This article will detail how you can assign, modify, or remove Office 365 licenses using the Set-MsolUserLicense command.

Please note that Set-MsolUserLicense is being deprecated, and you should switch to the Microsoft Graph API.

If you prefer to use a graphical user interface to manage Office 365 licenses, you should take a look at Easy365Manager.

Easy365Manager is a snap-in to AD Users & Computers that consolidates AD and Office 365 management.

With Easy365Manager, you can manage Office 365 licenses directly from user properties:

Alternatively, licenses can be managed using the Microsoft standard tools, the Azure Portal, and Microsoft 365 Admin Center.

Manage Office 365 Licenses With PowerShell

Before you assign licenses with PowerShell you need to define two options:

  • What License Plan(s) will you assign and/or remove
  • What Service Plan(s) do you want to disable in the License Plan

If you’re not 100% certain about the structure of License Plans and Service Plans have a look at this article.

If you’re assigning a license plan without disabling any service plans you can simply issue the following command (sample values):

Set-MsolUserLicense -UserPrincipalName -AddLicenses skrubbeltrang:ENTERPRISEPACK

This command will add the ENTERPRISEPACK (Office 365 E3) license to the user account with ALL service plans enabled.

If you wish to disable any of the service plans, then you’ll have to build a license options object.

The following code is an example on this:

$LO = New-MsolLicenseOptions -AccountSkuId "skrubbeltrang:ENTERPRISEPACK" -DisabledPlans "SHAREPOINTWAC", "SHAREPOINTENTERPRISE"
Set-MsolUserLicense -UserPrincipalName -LicenseOptions $LO

This command creates a license options object for the Office 365 E3 license plan with two SharePoint services disabled.

Then it assigns the settings to the user account.

For more details on license management, have a look at this article.