none
Script Errors when changing a Office 365 License Option... RRS feed

  • Question

  • Hello,

    I've assign my user Office 365 License with the MCOSTANDARD (Lync) Plan Disabled with the script below and this works great.

    $AccountSkuId="*******:ENTERPRISEPACK"
    $UsageLocation="US"
    $Users=Import-Csv C:\PC.csv
    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans "MCOSTANDARD"
    $Users | ForEach-Object {
    Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation
    Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId
    Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions $LicenseOptions
    }

    but now I would like to also disable another plan : EXCHANGE_S_ENTEPRISE (Exchange).  I run the following script.

    $AccountSkuId="********:ENTERPRISEPACK"
    $UsageLocation="US"
    $Users=Import-Csv C:\PC.csv
    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans "MSCOSTANDARD,EXCHANGE_S_ENTERPRISE"
    $Users | ForEach-Object {
    Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions $LicenseOptions

    I receive the below error on return.

    Set-MsolUserLicense : Unable to assign this license because the license
    options are invalid.
    At C:\UserLicenseScriptDisableLyncExch.ps1:6 char:1
    + Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions
    $Lic ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~
        + CategoryInfo          : OperationStopped: (:) [Set-MsolUserLicense], Mic
       rosoftOnlineException
        + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
       idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
      tUserLicense

    Please advise on how I can disable the additional option.  Thank you very much.

    Wednesday, June 24, 2015 5:55 PM

Answers

  • Microsoft Support is incorrect.  This will disable the Exchange_S_ENTERPRISE and MCOSTANDARD.

    $AccountSkuId="*******:ENTERPRISEPACK"
    $UsageLocation="US"
    $Users=Import-Csv C:\********.csv
    $DisabledOptions = @()
    $DisabledOptions += "EXCHANGE_S_ENTERPRISE"
    $DisabledOptions += "MCOSTANDARD"
    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans $DisabledOptions
    $Users | ForEach-Object {
    Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions $LicenseOptions
    }


    • Edited by TPham(RNDC) Friday, June 26, 2015 2:16 AM Incorrect Format..
    • Marked as answer by TPham(RNDC) Friday, June 26, 2015 2:16 AM
    Friday, June 26, 2015 2:14 AM

All replies

  • Try it this way:

    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans 'MSCOSTANDARD', 'EXCHANGE_S_ENTERPRISE'

    It is important that you knowhow to use the CmdLet help to resolve errors.  This CmdLet help states:

    -DisabledPlans <string[]>

    Notice that it is a string array and not a comma separated string.

    Use HELP.  It is your friend.  Don't be shy.  "Help" is a very nice friend.


    \_(ツ)_/


    • Edited by jrv Wednesday, June 24, 2015 9:41 PM
    Wednesday, June 24, 2015 9:41 PM
  • I ran it again like the below. Still the same error.

    $AccountSkuId="********:ENTERPRISEPACK"
    $UsageLocation="US"
    $Users=Import-Csv C:\*********.csv
    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans 'MSCOSTANDARD','EXCHANGE_S_ENTERPRISE'
    $Users | ForEach-Object {
    Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions $LicenseOptions
    }

    ERROR:

    Set-MsolUserLicense : Unable to assign this license because the license
    options are invalid.
    At C:\UserLicenseScriptDisableLyncExch.ps1:6 char:1
    + Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions
    $Lic ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ~~~
        + CategoryInfo          : OperationStopped: (:) [Set-MsolUserLicense], Mic
       rosoftOnlineException
        + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
       idUserLicenseOptionException,Microsoft.Online.Administration.Automation.Se
      tUserLicense

    Thursday, June 25, 2015 3:07 AM
  • One or both of the license names is invalid.  Try them one at a time to see which one is invalid.

    \_(ツ)_/


    • Edited by jrv Thursday, June 25, 2015 10:57 AM
    Thursday, June 25, 2015 10:56 AM
  • Hi JRV,

    When I disable them one at a time, it works fine but re-enables the other one.  It just when I try to disable both at a time when it tells me that it is invalid.

    Thursday, June 25, 2015 6:49 PM
  • $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans @('MSCOSTANDARD','EXCHANGE_S_ENTERPRISE')

    \_(ツ)_/

    Thursday, June 25, 2015 6:51 PM
  • I ran the below:

    $AccountSkuId="********:ENTERPRISEPACK"
    $UsageLocation="US"
    $Users=Import-Csv C:\********.csv
    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans @
    ('EXCHANGE_S_ENTERPRISE','MSCOSTANDARD')
    $Users | ForEach-Object {
    Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions $LicenseOptions
    }

    Error was this:

    At C:\UserLicenseScriptDisableLyncExch04.ps1:4 char:85
    + ... -DisabledPlans @
    +                    ~
    Unrecognized token in source text.
        + CategoryInfo          : ParserError: (:) [], ParseException
        + FullyQualifiedErrorId : UnrecognizedToken

    Thursday, June 25, 2015 7:26 PM
  • Microsoft Support is incorrect.  This will disable the Exchange_S_ENTERPRISE and MCOSTANDARD.

    $AccountSkuId="*******:ENTERPRISEPACK"
    $UsageLocation="US"
    $Users=Import-Csv C:\********.csv
    $DisabledOptions = @()
    $DisabledOptions += "EXCHANGE_S_ENTERPRISE"
    $DisabledOptions += "MCOSTANDARD"
    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId -DisabledPlans $DisabledOptions
    $Users | ForEach-Object {
    Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -LicenseOptions $LicenseOptions
    }


    • Edited by TPham(RNDC) Friday, June 26, 2015 2:16 AM Incorrect Format..
    • Marked as answer by TPham(RNDC) Friday, June 26, 2015 2:16 AM
    Friday, June 26, 2015 2:14 AM