The Get-AzureADUser command comes with a filtering function just like, e.g., Get-ADUser.
But if you’re expecting the power of the Get-ADUser LdapFilter switch or the PowerShell expression language Filter switch, then you’re in for a sad surprise…
The Get-AzureADUser filter is overly complex and lacks a lot of functionality.
Unfortunately, in most cases, your better option is to retrieve all user accounts and perform the filtering locally.
The below sections will demonstrate some uses of the Get-AzureADUser Filter options.
If you prefer a simple GUI instead of complex PowerShell scripts, have a look at EasyEntra:
EasyEntra is an intuitive tool for managing AD, hybrid AD, and cloud-only Entra ID. EasyEntra consolidates AD properties, cloud settings like MFA and cloud-only group membership, and EXO mailbox settings in a simple, intuitive UI.
EasyEntra is FOREVER FREE for pure AD management and for managing any tenant with fewer than 25 licensed users. It even supports side-by-side management of any number of ADs and tenants.
Download a fully functional 30-day trial here.
Get-AzureADUser Filter Operators
The Filter switch of the Get-AzureADUser command builds on oData v3.0 filtering.
This is contrary to the PowerShell expression language filter used by Get-ADUser -Filter, which again is different from the very basis Get-MsolUser -SearchString filter option.
For every new development team at Microsoft, there seems to be a new strategy… 🙄
The following details the basic operators available to Get-AzureADUser filtering:
| Operator | Meaning | Sample expression |
|---|---|---|
| eq | Equal to | DisplayName eq ‘Tycho Brahe’ |
| and | And | Country eq ‘Germany’ and Department eq ‘Marketing’ |
| or | Or | Country eq ‘Germany’ or Country eq ‘France’ |
Notice that the Like filter is not available – it’s impossible to search substrings in Azure AD user attributes, which makes the use cases very limited. The same goes for the Not filter and many more.
The only type of wildcard search available is the ‘startswith’ filter.
Additionally, it’s possible to search the values of multivalue attributes using the ‘any’ filter.
However, a big limitation of this is the inability to search complex object type attributes like ‘AssignedPlans’.
Get-AzureADUser Filter Examples
Below you’ll find some basic examples of the Get-AzureADUser filter syntax.
Get-AzureADUser -Filter "DisplayName eq 'Tycho Brahe'" Get-AzureADUser -Filter "Country eq 'Germany' and Department eq 'Marketing'" Get-AzureADUser -Filter "Country eq 'Germany' or Country eq 'France'" Get-AzureADUser -Filter "startswith(displayName,'Hans')" Get-AzureADUser -Filter "proxyAddresses/any(p:startswith(p,'smtp:hans'))" But as mentioned at the beginning of the article:
The use-cases of the Get-AzureADUser Filter parameter are very limited. In most cases, you’re forced to retrieve all users and perform the filtering locally, using the PowerShell expression language filter, e.g.:
Get-AzureADUser -All $true | Where-Object {$_.DisplayName -like "*hans*"} Get-AzureADUser -All $true | Where-Object {$_.AssignedPlans.Service -eq "SharePoint"} Although this approach may perform badly in large environments, it offers a lot more options and flexibility.
How to Manage AD and EXO Mailboxes In One Box
Many admins are frustrated that you need multiple web consoles and PowerShell modules to manage Microsoft 365.
With EasyEntra, all daily Microsoft 365 mailbox operations will become available directly in standard AD user properties. Even the configuration of calendar permissions, which is normally only available via complex PowerShell scripting:
If you’re looking to make your first-line helpdesk work efficiently and confidently, EasyEntra has got you covered.
✅ Reduced training of new Junior IT staff.
✅ No more escalation of (what should be) simple tickets to Senior IT.
✅ Automated onboarding and offboarding of users without complex, ever-changing PowerShell scripts.
Watch how EasyEntra fuses ease of use with complexity to make user offboarding fast, accessible, and consistent:
Still not convinced EasyEntra is worth giving a spin? This is what our clients have to say:
“One of the best products I’ve used.” – CIO, Mirick Law, United States
“We really love working with EasyEntra.” – Head of IT, IKN GmbH, Germany
“It feels almost like a revolution.” – IT Manager, Arjeplog Kommun, Sweden
Improve the efficiency of your helpdesk today: Download the 30-day trial.