Answered by:
Bulk assigning Office 365 licenses using PowerShell

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
icenseI have verified the license is valid. Any ideas? Thanks!
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
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
-
-
-
-
-
-
Here is the help template for adding a license:
Set-MsolUserLicense -UserPrincipalName user@contoso.com -AddLicenses "Contoso:ENTERPRISEPACK"
¯\_(ツ)_/¯
-
-
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
-
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 -
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.
¯\_(ツ)_/¯
-
-
-
-
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.
¯\_(ツ)_/¯
-
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