I wanted to apply an Office 365 (O365) license to a user via PowerShell:
PowerShell Command
Set-MsolUserLicense -UserPrincipalName "johndoe@example.com" -AddLicenses "exampletenant:EXCHANGESTANDARD_ALUMNI"
Error
Set-MsolUserLicense : You must provide a required property: Parameter name: UsageLocation
Fine. What is this UsageLocation parameter? See Assign licenses to user accounts with Office 365 PowerShell:
You can assign licenses only to user accounts that have the UsageLocation property set to a valid ISO 3166-1 alpha-2 country code. For example, US for the United States, and FR for France.
OK, so US for United States.
PowerShell Command
Set-MsolUserLicense -UserPrincipalName "johndoe@example.com" -AddLicenses "exampletenant:EXCHANGESTANDARD_ALUMNI" -UsageLocation US
Error
Set-MsolUserLicense : A parameter cannot be found that matches parameter name 'UsageLocation'.
Really, Microsoft? Is it a required parameter or is it not a parameter? Make up your minds!
Turns out, it’s a parameter of the Set-MsolUser cmdlet:
PowerShell Commands
Set-MsolUser -UserPrincipalName "johndoe@example.com" -UsageLocation US
Set-MsolUserLicense -UserPrincipalName "johndoe@example.com" -AddLicenses "exampletenant:EXCHANGESTANDARD_ALUMNI"
The license was applied successfully.
excellent! it worked
Worked for me too.
Is it a result of bad coding? How on earth a non-programmer without the use of google can find out what really the PS error wants to tell us.
Thank you very much!!
Very helpful, thank you for this. The errors thrown in this scenario are completely asinine.
Thanks!! This error was driving me crazy!
-usagelocation parameter not found
@praful can you provide any additional context?
Did you apply the
-UsageLocation
withSet-MsolUser
before runningSet-MsolUserLicense
?Set-MsolUserLicense
does not have a-UsageLocation
parameter, but it must be applied to the target user prior to runningSet-MsolUserLicense
.See the Microsoft documentation for details on each command:
I swear Microsoft is insane at times. Thank you for this. I was starting to make up curse words.
this worked thank you
Thank you, I was going insane.
if we want to use that to activate licences for an users _liste.csv file, how can we do it ?
the csv file have to containe just the mails ?
thank you for your help