none
Set-MsolUserLicense : Unable to assign this license because it is invalid. Use the Get-MsolAccountSku cmdlet to retrieve a list of valid licenses. RRS feed

  • Question

  • Set-MsolUserLicense : Unable to assign this license because it is invalid. Use the Get-MsolAccountSku cmdlet to retrieve a list of valid licenses.

    There is not one article available with a detailed sequence how to set licenses, this just adds to aggravation

    Step 1 Create the Service Plan (WORKS)

    $NewOL = New-MsolLicenseOptions -AccountSkuId "XXXXXXXXXXX:ENTERPRISEPACK" -DisabledPlans "Deskless,FLOW_O365_P2,POWERAPPS_O365_P2,INTUNE_O365,YAMMER_ENTERPRISE,RMS_S_ENTERPRISE,MCOSTANDARD,EXCHANGE_S_ENTERPRISE"

    Step 2 check what is set on user already (WORKS)

    (Get-MsolUser -UserPrincipalName XXXXXXXXXXX).Licenses[0].ServiceStatus

    PS C:\> Get-MsolAccountSku

    AccountSkuId                               ActiveUnits WarningUnits ConsumedUnits
    -------------------------               ---------------------- ------------------------ ----------------------------
    XXXXXXXXXX:RIGHTSMANAGEMENT_ADHOC 10000       0             0            
    XXXXXXXXXX:ENTERPRISEPACK         500                 0             20           
    XXXXXXXXXX:POWER_BI_STANDARD       1000000             0             2            

    Please tell me more on [0] what is that for, does this has anything to do with the addlicense command to be run

    Step 3 Remove the existing License set on user, as you addlicense doesnt work like that (FAILS)
    Set-MsolUserLicense -UserPrincipalName XXXXXX@XX -RemoveLicenses XXXXXXXXXX:ENTERPRIESEPACK

    PLEASE help with the complete understanding required here and also the Correct Command required to be executed


    An Extremist

    Monday, April 24, 2017 7:32 AM

All replies

  • [0] stands for the first item in a list, it's not the problem here. Since you are failing on the remove license operation, the only thing you need to check for is whether the user actually has the license in question assigned. In your case I can see that you are trying to remove the E3 license, but at the same time preparing a customized plan for the exact same license. So does the user currently have E3 assigned or not? If E3 is NOT assigned, it's expected that the cmdlet will fail with this error.

    Also, you do not need to remove the license if all you want to do is change the assigned services. Simply use the prepared $NewOL variable to update them:

    Set-MsolUserLicense -UserPrincipalName XXXXXX@XX -LicenseOptions $NewOL 

    And there are a lot of articles on this, even I have one :) http://www.michev.info/Blog/Post/1120/

    Monday, April 24, 2017 7:21 PM
  • Tried your suggestion
    Ensured the user has E3 license
    Ran the command as you suggested
    Nope No Luck still the same message

    PS C:\windows\system32> Set-MsolUserLicense -UserPrincipalName XXXXXXX@XX.com -LicenseOptions $NewOL
    Set-MsolUserLicense : Unable to assign this license because the license options are invalid.
    At line:1 char:1
    + Set-MsolUserLicense -UserPrincipalName XXXXXXX@XX.com -License ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (:) [Set-MsolUserLicense], MicrosoftOnlineException
        + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidUserLicenseOptionException,Microsoft.Online.Administration.Automation.SetUserLicense


    That's why I said not one article that summarizes well as to what all needs to be taken into consideration
    while preparing and assigning custom service plans for your users





    An Extremist

    Tuesday, April 25, 2017 4:45 AM
  • No, it's simply something I failed to notice in your original question. You are passing a String value for the LicenseOptions variable, it needs to be a list. In other words:

    (this will NOT work)

    $NewOL = New-MsolLicenseOptions -AccountSkuId "XXXXXXXXXXX:ENTERPRISEPACK" -DisabledPlans "Deskless,FLOW_O365_P2"

    (this will work)

    $NewOL = New-MsolLicenseOptions -AccountSkuId "XXXXXXXXXXX:ENTERPRISEPACK" -DisabledPlans "Deskless","FLOW_O365_P2"

    Simply add the rest.

    Tuesday, April 25, 2017 5:44 AM
  • I did test that earlier, however I am going to test it again as you suggest

    An Extremist

    Tuesday, April 25, 2017 5:46 AM
  • Great this time it has worked right away

    An Extremist

    Tuesday, April 25, 2017 5:48 AM
  • Glad to help, and sorry for missing it in the first post :)

    If you think this is complicated, wait to see how licensing is done in the AzureAD PowerShell module (the replacement for the MSOL cmdlets).

    Tuesday, April 25, 2017 6:52 AM
  • Hi ,

    Try this way out.

    Find the Provisioned service plans for the user using the below PS cmdlet

    (Get-MsolUser -UserPrincipalName test@test.com).Licenses.ServiceStatus

    Create a licenseoption that disables the services included in the licensing plan named XXXXX:ENTERPRISEPACK

    $LO = New-MsolLicenseOptions -AccountSkuId "XXXXX:ENTERPRISEPACK" -DisabledPlans "SHAREPOINTWAC", "SHAREPOINTENTERPRISE"

    (In the above example it disables Office Online and SharePoint Online services and please add required service plans you need to remove from the user)

    Set-MsolUserLicense -UserPrincipalName test@test.com -LicenseOptions $LO

    And see whether services are removed.

    And to add further i have noted that some times some services are not allowed to remove as there may be some dependency services connected to one another,

    Ex: inorder to remove sharepoint online you have to first remove Office online and then try to remove the sharepoint online service. 

    I hope you have tried the O365 portal to remove/provision licenses and services once you faced this problem :)

    Regards,

    Shenuka Fernando


    Tuesday, April 25, 2017 7:33 AM
  • Exactly that is what my initial point was, that article must guide you starting with collecting details for your tenant and then assist you how to interpret those/these collected details

    and then assist you with the steps needs to be performed, the second point no article talks or explains which services are dependents and how to Toggle them (enable / disable)

    Nevertheless, I thank you both for all the help on this,

    Now I am looking for using which all options or features I can Automate the License Assignment
    again thanks in advance to you,

    BR,


    An Extremist

    Wednesday, April 26, 2017 6:51 AM