Disable Office 365 License Option \ Product For Multiple Users

Following my new Office 365 PowerShell series and previous article today I’ll show you how to disable specific license feature for multiple users using PowerShell.

The script below will allow you to customize Office 365 licensing option and apply them to multiple users using .SCV file.

Using the table below I’ll specify In the script what products the users will see and have available In their Office 365 subscription.

PROJECTWORKMANAGEMENT Microsoft Project
SWAY Sway
INTUNE_O365 Intune
YAMMER_ENTERPRISE Yammer
RMS_S_ENTERPRISE RMS
OFFICESUBSCRIPTION Office Pro Plus 2016
MCOSTANDARD Skype For Business
SHAREPOINTWAC Office Web Apps
SHAREPOINTENTERPRISE SharePoint
EXCHANGE_S_ENTERPRISE Exchange

In my case I’m creating a custom license set that will only allow Exchange Mailbox and will disable all options \ products.

How to run the script:

  1. Fill in your all the details with your Tenant details (where you see CHANGE).
  2. Create a CSV file with all the Users IDs as seen below

$powerUser = "CHANGE"
 

$powerPass = "CHANGE"
 

$password = ConvertTo-SecureString $powerPass -AsPlainText -Force

$adminCredential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $powerUser,$password

$O365Cred = $adminCredential

Connect-MsolService –Credential $O365Cred

$E3 = New-MsolLicenseOptions -AccountSkuId "CHANGE:ENTERPRISEPACK" -DisabledPlans "OFFICESUBSCRIPTION","SHAREPOINTWAC","MCOSTANDARD","SHAREPOINTENTERPRISE","RMS_S_ENTERPRISE","YAMMER_ENTERPRISE","INTUNE_O365","SWAY","PROJECTWORKMANAGEMENT"

Import-Csv Users.csv | Foreach {Set-MsolUserLicense -UserPrincipalName $_.UPN -RemoveLicenses "CHANGE:ENTERPRISEPACK"}

Import-Csv Users.csv | Foreach {Set-MsolUserLicense -UserPrincipalName $_.UPN -RemoveLicenses "CHANGE:STANDARDPACK"}

Start-Sleep 10

Import-Csv Users.csv | Foreach {Set-MsolUserLicense -UserPrincipalName $_.UPN -addLicenses "CHANGE:ENTERPRISEPACK" -LicenseOptions $e3}

Posted

in

by