License assignment failed – License cannot be assigned to a user without a usage location specified

By | July 9, 2022

If you are getting the error above when assigning licenses, it is because the entry UsageLocation isn’t set for the user.

This image has an empty alt attribute; its file name is Usagelocation.jpg

The quick way to fix the issue is obviously to set the entry manually.

If you want to apply the change to larger number of users, the code snippet below may help:

Write-Host 'Please wait a moment...' -BackgroundColor DarkGreen -ForegroundColor White
$users = Get-AzureADUser
Write-Host 'Total number of users: '$users.Count
foreach($user in $users){
Set-AzureADUser -ObjectId $user.ObjectId -UsageLocation DE
Write-Host 'UsageLocation set for ' $user.DisplayName -BackgroundColor DarkGreen -ForegroundColor White
Write-Host 'Something went wrong' -BackgroundColor DarkRed -ForegroundColor Yellow
Write-Host $_ -BackgroundColor DarkRed -ForegroundColor Yellow

Mind that there are alternative options, see the links below.


What is group-based licensing in Azure Active Directory?


Set Office 365 UsageLocation property with Azure automation

Leave a Reply

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