Set-MsolUserLicense : A parameter cannot be found that matches parameter name ‘UsageLocation’

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.

10 thoughts on “Set-MsolUserLicense : A parameter cannot be found that matches parameter name ‘UsageLocation’”

  1. 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.

  2. @praful can you provide any additional context?

    Did you apply the -UsageLocation with Set-MsolUser before running Set-MsolUserLicense? Set-MsolUserLicense does not have a -UsageLocation parameter, but it must be applied to the target user prior to running Set-MsolUserLicense.

    See the Microsoft documentation for details on each command:

  3. I swear Microsoft is insane at times. Thank you for this. I was starting to make up curse words.

  4. 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

Leave a Reply

Your email address will not be published. Required fields are marked *