Home » Office 365 » Set-MsolUserLicense – Update License Assignment for a User

Set-MsolUserLicense – Update License Assignment for a User

The Set-MsolUserLicense cmdlet in PowerShell updates a license assignment for a user in Microsoft Office 365. This command can add a new license, remove a license, or update the license options.

The syntax to add a license to a user in Azure Active Directory is given below.

Set-MsolUserLicense
   -ObjectId <Guid>
   -UserPrincipalName <String>
   [-LicenseOptions <LicenseOption[]>]
   [-AddLicenses <String[]>]
   [-RemoveLicenses <String[]>]
   [-TenantId <Guid>]
   [<CommonParameters>]

Note: The Set-MsolUserLicense cmdlet is deprecated. Use Microsoft Graph PowerShell API to assign the licenses.

In this article, we will discuss how to use the Set-MsolLicense cmdlet in PowerShell to add a license to a user.

How to Add a License to User in Office 365

To add a license to a user in Office 365, use the Set-MsolUserLicense cmdlet with the -AddLicenses parameter. The -AddLicenses parameter specifies an array of licenses to assign to a user.

Set-MsolUserLicense -UserPrincipalName "[email protected]" -AddLicenses "shellgeeklab:ENTERPRISEPACK" 

This command adds the Office 365 for Enterprise license to the user specified by the -UserPrincipalName parameter.

Note here, that the Set-MsolUserLicense cmdlet is retired. Use the Microsoft Graph PowerShell cmdlets such as Set-MgUserLicense to assign the license.

How to Remove a License From a User

To remove a license from a user in Office 365, use the Set-MsolUserLicense cmdlet with the -RemoveLicenses parameter. The -RemoveLicenses parameter specifies an array of licenses to remove from a user.

Set-MsolUserLicense -UserPrincipalName "[email protected]" -RemoveLicenses "shellgeeklab:ENTERPRISEPACK" 

This command removes a license from the user in Azure Active Directory.

Conclusion

I hope the above article on how to use the Set-MsolUserLicense cmdlet in PowerShell to update the license for a user in Azure Active Directory is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Related Links

Set-MsolUserPassword

Set-MsolUserPrincipalName