none
Error Disabling Licenses to O365 User RRS feed

  • Question

  • 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. :)

    Wednesday, July 11, 2018 8:21 AM

Answers

  • You need to use an array of strings and not a string with commas.

    $services='RMS_S_ENTERPRISE',  'SHAREPOINTENTERPRISE,SHAREPOINTWAC'



    \_(ツ)_/


    • Edited by jrvModerator Wednesday, July 11, 2018 8:34 AM
    • Marked as answer by Sujeet Padhi Wednesday, July 11, 2018 11:11 AM
    Wednesday, July 11, 2018 8:34 AM
    Moderator

All replies

  • You need to use an array of strings and not a string with commas.

    $services='RMS_S_ENTERPRISE',  'SHAREPOINTENTERPRISE,SHAREPOINTWAC'



    \_(ツ)_/


    • Edited by jrvModerator Wednesday, July 11, 2018 8:34 AM
    • Marked as answer by Sujeet Padhi Wednesday, July 11, 2018 11:11 AM
    Wednesday, July 11, 2018 8:34 AM
    Moderator
  • Thanks a lot :) !!! It is working now.
    Wednesday, July 11, 2018 11:11 AM