Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ninmonkey/faf63efcd5477d6d62d090affb1bfb34 to your computer and use it in GitHub Desktop.
Save ninmonkey/faf63efcd5477d6d62d090affb1bfb34 to your computer and use it in GitHub Desktop.
Get-ADUser verses Get-AzureADUser filtering syntax

Get-ADUser verses Get-AzureADUser filtering syntax

Get-ADUser -Filter

Filters using Powershell scriptblocks

Ex:

Get-ADUser -Filter "Name -eq 'Fred Johnson'"

Get-AzureADUser -Filter and Get-AzureADGroup -Filter

AzureAD filters using OData queries

Ex:

$email = "jsmith"
Get-AzureADUser -Filter "startswith(Mail,'$email')"
Get-AzureADGroup -Filter "DisplayName eq 'Exchange Servers'"
Get-AzureADUser -Filter "userPrincipalName eq 'jsmith@company.com'"

The function startswith() and operator eq are just two of many that OData supports

List of OData filtering functions and operators

Docs: Get-AzureADUser examples

The old OData docs: https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2015/developers-guide/gg309461\(v=crm.7\)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment