User Tools

Site Tools


how_to_change_licence_of_a_user

How to change a licence for a Office 365 user

1. Connect to the tenant

Connect-MsolService

$UserCredential = Get-Credential "administrator@<tenant>"
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session

2. Getting the list of Office 365 services

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

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
EXCHANGE_S_ENTERPRISE   

3. See what licence is set to a user :

$userLicenseTest = Get-MsolUser -UserPrincipalName "user@<tenant"
$userLicenseTest.IsLicensed
$userLicenseTest.Licenses.Count
$userLicenseTest.Licenses[0].ServiceStatus
$userLicenseTest.Licenses[1].ServiceStatus

Or use this script :

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

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 : [[https://portal.office.com]]
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: 2017/06/28 11:21 by admin