Office 365 Set-MsolUserLicense: "Unable to assign this license because the license options are invalid" error RRS feed

  • Question

  • I created a script to automatically add E3 licenses for new users and disable the service plans we don't want then to have.  I've tested with a test account and it worked just fine.  However, when attempting to run with new accounts, I keep getting the dreaded "Set-MsolUserLicense: Unable to assign this license because the license options are invalid" error.  Frustrated, I manually added the licenses to the users in Admin Center.  

    But then I went back and ran the script again with the same users to assign and this time it ran with no errors. can't assign licenses via PowerShell unless you first manually assign them in Admin Center?  That doesn't make sense nor explains why the script ran just fine with the test account previously.  Below is my script:

    $ScriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition

    $E3 = "Contoso:ENTERPRISEPACK"

    $Basic = New-MsolLicenseOptions -AccountSkuId $E3 -DisabledPlans KAIZALA_O365_P3,WHITEBOARD_PLAN2,MYANALYTICS_P2,BPOS_S_TODO_2,FORMS_PLAN_E3, `




    $MyUsers = import-csv -path "$ScriptPath\Migration.csv"

    foreach($user in $MyUsers)


            Set-MsolUser -UserPrincipalName $user.Userprincipalname -UsageLocation US

            Set-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -LicenseOptions $Basic


    Monday, October 7, 2019 12:54 PM

All replies