Unable to apply the -LicenseOptions when running the add license to user via script. The script does apply the Enterprise Pack. However, it does not disable plans. In this case I'm trying to disable the Lync online plan. I receive the error " Set-MsolUserLicense : Unable to assign this License because the license options are invalid" I'm attempting to disable Lync online when applying the License.
$O365Licences = New-MsolLicenseOptions AccountSkuId "xxxx365:ENTERPRISEPACK" -DisabledPlans MSCOSTNADARD$Licenseuser = get-mailbox -resultsize unlimited |Where-Object {$_.CustomAttribute7 -eq "LicenseMe"}
Foreach($EachUser in $LicenseUser){
Set-Msoluser -userPrincipalName $Eachuser.userprincipalname -UsageLocation "US"
Set-MsoluserLicense -userPrincipalName $Eachuser.userprincipalname -AddLicenses $O365Licences
Get-Msoluser -UserPrincipalName $eachuser.UserPrincipalnameSet |Set-MsoluserLicense -LicenseOptions $O365Licences
}