none
Bulk assigning Office 365 licenses using PowerShell RRS feed

  • Question

  • I've completed this in the past successfully but I'm running into some issues this time.  Below is the PowerShell script I'm running:

    Connect-MSOLService -Credential $adminCredential

    $AccountSkuId = "msllbc:OFFICESUBSCRIPTION_STUDENT"

    $UsageLocation = "US"

    $LicenseOptions = New-MsolLicenseOptions -AccountSkuId $AccountSkuId

    $Users = Import-Csv c:\Users.csv

    $Users | ForEach-Object {

    Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation

    Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId -LicenseOptions $LicenseOptions

    }

    This is the error I'm receiving:

    Set-MsolUserLicense : Unable to assign this license because it is invalid. Use
    the Get-MsolAccountSku cmdlet to retrieve a list of valid licenses.
    At C:\Add_License_New.ps1:14 char:20
    + Set-MsolUserLicense <<<<  -UserPrincipalName $_.UserPrincipalName -AddLicense
    s $AccountSkuId -LicenseOptions $LicenseOptions
        + CategoryInfo          : OperationStopped: (:) [Set-MsolUserLicense], Mic
       rosoftOnlineException
        + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
       idUserLicenseException,Microsoft.Online.Administration.Automation.SetUserL
      icense

    I have verified the license is valid.  Any ideas?  Thanks!

    Thursday, August 28, 2014 2:41 PM

Answers

  • Here's something funny.  I noticed there were 21 active users for that license which was strange since I only applied a couple manually.  Even though the script is throwing those errors it is still being applied.  I ran the script again and ignored the errors and it completed successfully.  Not sure why but at this point I don't care too much!  lol
    • Marked as answer by Seth7 Friday, August 29, 2014 12:16 PM
    Friday, August 29, 2014 12:16 PM

All replies

  • Did you follow the instructions and look up the valid licenses?

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


    ¯\_(ツ)_/¯


    • Edited by jrv Thursday, August 28, 2014 3:03 PM
    Thursday, August 28, 2014 3:03 PM
  • Yes, I have used the Get-MsolAccountSku cmdlet. 
    Thursday, August 28, 2014 3:40 PM
  • Yes, I have used the Get-MsolAccountSku cmdlet. 

    Is the license SKU listed?


    ¯\_(ツ)_/¯

    Thursday, August 28, 2014 3:42 PM
  • Yes, it is listed and was able to get it to work, sporadically, by only having one email address in the user.csv file.
    Thursday, August 28, 2014 3:52 PM
  • You are adding the SKU twice.  Once in Options and once in the Set.


    ¯\_(ツ)_/¯

    Thursday, August 28, 2014 3:56 PM
  • This should work:

    $Users | 
         ForEach-Object{
              Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId
        }


    ¯\_(ツ)_/¯

    Thursday, August 28, 2014 4:00 PM
  • Here is the help template for adding a license:

    Set-MsolUserLicense -UserPrincipalName user@contoso.com -AddLicenses "Contoso:ENTERPRISEPACK"


    ¯\_(ツ)_/¯

    Thursday, August 28, 2014 4:01 PM
  • Actually that is how it is recommended to run it but I did try removing that and I receive the same error.
    Thursday, August 28, 2014 4:03 PM
  • Options is only required of you want to disable license components.  You are doing everything twice.  Just add the license to the user using the UPN.

    Read the help for the CmdLets including the examples.


    ¯\_(ツ)_/¯


    • Edited by jrv Thursday, August 28, 2014 4:05 PM
    Thursday, August 28, 2014 4:05 PM
  • When I remove it this is the error I get (just about the same):

    Set-MsolUserLicense : Unable to assign this license because it is invalid. Use
    the Get-MsolAccountSku cmdlet to retrieve a list of valid licenses.
    At line:3 char:20
    + Set-MsolUserLicense <<<<  -UserPrincipalName $_.UserPrincipalName -AddLicense
    s $AccountSkuId
        + CategoryInfo          : OperationStopped: (:) [Set-MsolUserLicense], Mic
       rosoftOnlineException
        + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.Inval
       idUserLicenseException,Microsoft.Online.Administration.Automation.SetUserL
      icense

    Thursday, August 28, 2014 4:28 PM
  • The license is not valid.  It may have no more uses or you may have activation issues.  Just place a support call to Microsoft.

    Look at the exact error:

    Microsoft.Online.Administration.Automation.InvalidUserLicenseException,Microsoft.Online.Administration.Automation.SetUserLicense

    This is an  invalid license SkuID: msllbc:OFFICESUBSCRIPTION_STUDENT

    You need to use a SkuID.

    The student options may also need extra validation.  Post in the Office365 forum for quick assistance.  Post the exact and complete error message.


    ¯\_(ツ)_/¯

    Thursday, August 28, 2014 4:50 PM
  • Ok, do you think it has anything to do with the full skuid name not being displayed (in my picture below)?

    


    • Edited by Seth7 Thursday, August 28, 2014 5:14 PM
    Thursday, August 28, 2014 4:56 PM
  • Get-MsolAccountSku | Format-List

    This will display the complete Skuid.


    ¯\_(ツ)_/¯

    Thursday, August 28, 2014 5:30 PM
  • Yup, that's what I have listed.  I guess I need to open a case with Microsoft.  Thanks for your help if you have any other ideas I'd appreciate the help.  Thanks again!
    Thursday, August 28, 2014 5:47 PM
  • Yup, that's what I have listed.  I guess I need to open a case with Microsoft.  Thanks for your help if you have any other ideas I'd appreciate the help.  Thanks again!

    Since the student licenses are special, there may be other issues when assigning using PowerShell.  Posting in the O365 forum or contacting support will likely get you a better answer.


    ¯\_(ツ)_/¯

    Thursday, August 28, 2014 5:49 PM
  • Here's something funny.  I noticed there were 21 active users for that license which was strange since I only applied a couple manually.  Even though the script is throwing those errors it is still being applied.  I ran the script again and ignored the errors and it completed successfully.  Not sure why but at this point I don't care too much!  lol
    • Marked as answer by Seth7 Friday, August 29, 2014 12:16 PM
    Friday, August 29, 2014 12:16 PM