Forum Discussion

Scott B's avatar
Scott B
Copper Contributor
Jul 10, 2017

License plan disabled options not working in MSOL Powershell

I'm working on some code based on this TechNet post:

https://technet.microsoft.com/en-us/library/dn771769.aspx

 

Whether I list the disabled plans as a comma separated string or an array it's not working. Any help is appreciated.

 

$disabled_plans = @()
$disabled_plans += RMS_S_ENTERPRISE
$disabled_plans += BI_AZURE_P2
$disabled_plans += MCOMEETADV

$AccountSkuId = 'tenantid:ENTERPRISEPREMIUM'

$disabled_options = New-MsolLicenseOptions -AccountSkuId $AccountSkuId –DisabledPlans $disabled_plans
Set-MsolUserLicense -UserPrincipalName joe.smith@tenantid.com -LicenseOptions $disabled_options

6 Replies

  • Jeremy Dahl's avatar
    Jeremy Dahl
    Brass Contributor

    Hey Scott, 

    I tried your code, and got an error because the $disabledplans options where being treated as cmdlets, and not options - I enclosed them in quotes, and it worked exactly as you'd expect:

     

    $disabled_plans = @()
    $disabled_plans += "RMS_S_ENTERPRISE"
    $disabled_plans += "SWAY"
    $disabled_plans += "YAMMER_ENTERPRISE"

     

    I didn't have the exact same license options as you, I just chose three from my EnterprisePack and disabled them. Have you already tried it with the quotes? It should work just fine.

     

    Mind you, my test user DID already have the EnterprisePack assigned to them (like Vasil pointed out), so if you're assigning new licenses then you'll need to follow his instructions. If you're simply removing extra license components after the fact, your script should do the job.

  • The example you are using will only work when the user laready has the ENTERPRISEPREMIUM SKU assigned, it will not work if you are just assigning a new license. For the latter, you need to also specify the -AddLicense parameter. And if you are using array, you need to add quotes around the service plans to make sure they're recognized as strings.

     

    Lastly, MCOMEETADV can be an actual SKU (license), not a service plan, if purchased outside of the E5. If that's the case, you should not use it with the $disabled_plans variable, but treat it like actual license instead.

    • Scott B's avatar
      Scott B
      Copper Contributor

      Hi Vasil,

       

      Thanks for reply. When I copied/pasted I somehow lost the quotes but my original code has them.

       

      I have also tried the way you suggested by adding the bundle first then applying the disabled options. However that does not work either as the options selected never get disabled. Even If I try disabling just one plan nothing happens.

      • Jeremy Dahl's avatar
        Jeremy Dahl
        Brass Contributor

        Scott, what's your scenario? Are you trying to use this to assign new licenses to unlicensed users, or are you trying to remove license options from people that already have the license pack assigned?

Resources