Unsupported or invalid query filter clause specified for property ‘userState’ of resource ‘User’.

Get-AzureADUser -SearchString $user.UserName

A variable $user passes the search string for UserName along with other properties. The expected result is to return the matching users as demonstrated below. This is from Example 3: Search among retrieved users here.

Get-AzureADUser -SearchString "New"

ObjectId                             DisplayName UserPrincipalName                   UserType
--------                             ----------- -----------------                   --------
5e8b0f4d-2cd4-4e17-9467-b0f6a5c0c4d0 New user    NewUser@contoso.onmicrosoft.com     Member
2b450b8e-1db6-42cb-a545-1b05eb8a358b New user    NewTestUser@contoso.onmicrosoft.com Member

For me, instead it returned this error

Unsupported or invalid query filter clause specified for property 'userState' of resource 'User'.

It turns out there is a bug in the AzureAD module which has been fixed in the latest module. You want to take the latest build for obvious reasons. In case you can’t for some reason, you could also use an alternate option with a different command-set as follows.

Get-AzureADUser -ObjectId $user.UserName #pass the full user name of course

Hope it saves someone few mins…

Leave a comment