I am trying to locate accounts matching a certain phrase in my Azure Active Directory instance. The phrase needs to be case insensitive, however I am not finding a way to do that. All sorts of posts direct me to user 'lower' or 'tolower', which results in the error below.
"Invalid jmespath query supplied for
--query
: Unknown function: lower()"
Here is what I currently have for a case sensitive search.
az ad user list --query "[?contains(displayName, 'Phrase')]"
This works great if I am trying to match 'Phrase', but fails on 'phrase', 'pHrAse', 'PHRASE', etc.
In my tenant, I have 4 Entra ID users named Sridemo in different cases like this:
When I tried to retrieve these users by doing case insensitive search using
tolower()
method, I too got same error:Response:
Alternatively, you can make use of below query that initially retrieves all users and filters them by display name converting to lower case:
When I ran below script, I got response with expected details along with their count like this:
Response: