Finding Unlicensed Users in O365

Use these commands to check which users don’t have a license or need a different license. This is different from the search/filter in the Admin portal because it checks for the LicenseReconciliationNeeded attribute rather than IsLicensed. For example if you have a user with an Azure AD P2 license but they need an Exchange Online license the admin portal doesn’t give you a good way to filter this out.

#get connected
Connect-MsolService

#show list of users that we need to license
get-msoluser -All | where {$_.LicenseReconciliationNeeded -eq $true}

#show the availible licenses that we have in the tenant, we are going to be looking for the E3 license "tenantnamehere:ENTERPRISEPACK"
Get-MsolAccountSku

#assign a usage location to the users we are going to license
get-msoluser -All | where {$_.LicenseReconciliationNeeded -eq $true} |Set-MsolUser -UsageLocation "US"

#assign the licenses to the users
get-msoluser -All | where {$_.LicenseReconciliationNeeded -eq $true} |Set-MsolUserLicense -AddLicenses "tenantnamehere:ENTERPRISEPACK"

Your users should be all set with their new licenses.

Leave a comment