'How to remove specific service plan from O365 license using powershell

I have the following script to apply a DESKLESS license

Connect-MsolService
Import-Csv 'C:\users.CSV' | foreach {Set-MsolUser -UserPrincipalName $_.EmailAdress -UsageLocation BR
Set-MsolUserLicense -UserPrincipalName $_.EmailAdress -AddLicenses mydomain:DESKLESSPACK
$accountSkuId="mydomain:DESKLESSPACK"
$planList= ("FLOW_O365_S1","KAIZALA_O365_P1")
$licenseOptions= New-MsolLicenseOptions -AccountSkuId $accountSkuId -DisabledPlans $planList
}

The script runs fine, but when I check the users license nothing changes in the license service plans. FLOW_O365_S1 and KAIZALA_O365_P1 are still enabled along with all the rest. Is there a simple way to do it ? I found some really complex scripts on github that might help but they are huge.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source