When provisioning user accounts in Office365 via PowerShell you may encounter an issue when trying to assign a licence sku to the user account for Office365 Services.

As an example i have added some PowerShell commands below to illustrate the creation process of a user in Office365 via PowerShell.

$msolcred = get-credential
connect-msolservice -credential $msolcred

$msolsku = get-msolaccountsku
New-MsolUser -UserPrincipalName test@contoso.com -FirstName “Firstname” -LastName “Lastname” -DisplayName “Firstname Lastname”
Set-MsolUserLicense -UserPrincipalName test@contoso.com -AddLicenses $msolsku

You will encounter an error if you try to add a licence sku to the account:

Set-MsolUserLicense : You must provide a required property: Parameter name: UsageLocation

The UsageLocation is a parameter that ties into Microsoft Online Services International Availability, and without configuring it you will not be able to assign licences to a user account.

This setting can be configured via the Set-MsolUser cmdlett in the following manner:

Set-MsolUser -UserPrincipalName test@contoso.com -UsageLocation <countrycode>

The sku can now be configured for the account.

Set-MsolUserLicense -UserPrincipalName test@contoso.com -AddLicenses $msolsku

Alternatively you can add this setting to your scripts when creating your accounts.

New-MsolUser -UserPrincipalName test@contoso.com -FirstName “Firstname” -LastName “Lastname” -DisplayName “Firstname Lastname” -UsageLocation <countrycode>


If you are uncertain what your or your client’s country code is you can look them up by country at the “International Organization for Standardization” website: https://www.iso.org/obp/ui/#search