User Tools

Site Tools


How to change a licence for a Office 365 user

1. Connect to the tenant


$UserCredential = Get-Credential "administrator@<tenant>"
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

2. Getting the list of Office 365 services

$E3 = Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq 'ENTERPRISEPACK'}

Here an example of services :

ServicePlan                                                 ProvisioningStatus

-----------                                                 ------------------
FLOW_O365_P2                                                Success
POWERAPPS_O365_P2                                           Success
TEAMS1                                                      Success
PROJECTWORKMANAGEMENT (msproject)                           Success
SWAY                                                        Success
INTUNE_O365   (mdm mobile)                                  Success
YAMMER_ENTERPRISE                                           Success
RMS_S_ENTERPRISE   (document access control)                Success
OFFICESUBSCRIPTION                                          Success
MCOSTANDARD  (skype)                                        Success
SHAREPOINTWAC          (office online)                      Success
SHAREPOINTENTERPRISE                                        Success

3. See what licence is set to a user :

$userLicenseTest = Get-MsolUser -UserPrincipalName "user@tenant"

Or use this script :

$licensedetails = (Get-MsolUser -UserPrincipalName "user@tenant").Licenses
# If there's a license, show the details. # Otherwise, the output is blank.
if ($licensedetails.Count -gt 0){
  foreach ($i in $licensedetails){

4. Adding or removing licence to a user :

!!! You need to understand those licences in “DisabledPlans” section are going to be disabled, if you want to activate a licence, remove it from “DisabledPlans” !!!

# get the licence status
$E3 = Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq 'ENTERPRISEPACK'}
$VarLicence1 = $E3.AccountSkuID
# set the unwanted licence
$VarLicence1_Not_Allowed = New-MsolLicenseOptions -AccountSkuId $E3.AccountSkuID -DisabledPlans FLOW_O365_P2,INTUNE_O365,POWERAPPS_O365_P2,RMS_S_ENTERPRISE,YAMMER_ENTERPRISE

# remove all licence of the user OR Disable all licences in admin page of office : [[]]
Set-MsolUserLicense -UserPrincipalName user@<tenant> -RemoveLicenses $E3.AccountSkuID

#set full licence to user
Set-MsolUserLicense -UserPrincipalName user@<tenant> -AddLicenses $VarLicence1
#remove unwanted licence to user
Set-MsolUserLicense -UserPrincipalName user@<tenant> -LicenseOptions $VarLicence1_Not_Allowed

Go to the section “3” for see the result.

5. Disconnect the remote session :

Remove-PSSession $Session

Source1 : windowsippro

Source2 : technet

- created date : 2017.04.04 -

how_to_change_licence_of_a_user.txt · Last modified: 2019/02/25 12:38 (external edit)