Assign Office 365 License with PowerShell

Please refer to the steps below on how to assign office 365 license with powershell

  1. List all the ServicePlan for E3
#Office 365 License for E3 
Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq 'ENTERPRISEPACK'} |
   ForEach-Object {$_.ServiceStatus}

ServicePlan           ProvisioningStatus
-----------           ------------------
BPOS_S_TODO_2         Success           
FORMS_PLAN_E3         Success           
STREAM_O365_E3        Success           
Deskless              Success           
FLOW_O365_P2          Success           
POWERAPPS_O365_P2     Success           
TEAMS1                Success           
PROJECTWORKMANAGEMENT Success           
SWAY                  Success           
INTUNE_O365           PendingActivation 
YAMMER_ENTERPRISE     Success           
RMS_S_ENTERPRISE      Success           
OFFICESUBSCRIPTION    Success           
MCOSTANDARD           Success           
SHAREPOINTWAC         Success           
SHAREPOINTENTERPRISE  Success           
EXCHANGE_S_ENTERPRISE Success           
  1. Define the ServerPlan you would like to disable, like ExchangeOnline
$UPN = "[email protected]"
$AccountSKU = Get-MsolAccountSku | ? AccountSkuID -like "*ENTERPRISEPACK"
$ExchangeOnline = "EXCHANGE_S_ENTERPRISE"
$OfficeProPlus = "OFFICESUBSCRIPTION" 
  1. Verify that user had been configured with UsageLocation & isLicensed
if ((Get-MsolUser -UserPrincipalName $UPN).UsageLocation -and (Get-MsolUser -UserPrincipalName $UPN).isLicensed) {} 
else {

    Set-MsolUser -UserPrincipalName $UPN -UsageLocation MY
    Set-MsolUserLicense -UserPrincipalName $UPN -AddLicenses $AccountSKU.AccountSkuId

} 

#Disable ExchangeOnline & OfficeProPlus
    $LicenseOption = New-MsolLicenseOptions -AccountSkuId $AccountSKU.AccountSkuId -DisabledPlans $ExchangeOnline,$OfficeProPlus
    Set-MsolUserLicense -UserPrincipalName $UPN -LicenseOptions $LicenseOption
  1. Verify that ExchangeOnline and OfficeProPlus is disabled
#Check License assigned for individual User
$MsolUser = Get-MsolUser -UserPrincipalName $UPN 
$MsolUser.Licenses.ServiceStatus

ServicePlan           ProvisioningStatus
-----------           ------------------
BPOS_S_TODO_2         Success           
FORMS_PLAN_E3         Success           
STREAM_O365_E3        Success           
Deskless              Success           
FLOW_O365_P2          Success           
POWERAPPS_O365_P2     Success           
TEAMS1                Success           
PROJECTWORKMANAGEMENT Success           
SWAY                  Success           
INTUNE_O365           PendingActivation 
YAMMER_ENTERPRISE     Success           
RMS_S_ENTERPRISE      Success           
OFFICESUBSCRIPTION    Disabled          
MCOSTANDARD           Success           
SHAREPOINTWAC         Success           
SHAREPOINTENTERPRISE  Success           
EXCHANGE_S_ENTERPRISE Disabled

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top