I am trying to Disable some services (Present in the License) for an O365 User.
Below code works fine.
$O365Sku = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans RMS_S_ENTERPRISE,SHAREPOINTENTERPRISE,SHAREPOINTWAC
Set-MsolUserLicense -UserPrincipalName $Identity@$DomainUpn -LicenseOptions $O365Sku
But when I keep the Services in a variable like below it does not work and throws error.
$services="RMS_S_ENTERPRISE,SHAREPOINTENTERPRISE,SHAREPOINTWAC"
$O365Sku = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans $services
Set-MsolUserLicense -UserPrincipalName $Identity@$DomainUpn -LicenseOptions $O365Sku
Error:
PS C:\Users\spadhi> Set-MsolUserLicense -UserPrincipalName $Identity@$DomainUpn -LicenseOptions $O365Sku
Set-MsolUserLicense : Unable to assign this license because the license options are invalid.
At line:1 char:1
+ Set-MsolUserLicense -UserPrincipalName $Identity@$DomainUpn -LicenseO ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Set-MsolUserLicense], MicrosoftOnlineException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidUserLicenseOptionException,Microsoft.Online.Administration.Automation.SetUserLicense
Please help. Thanks is advance. :)