'set multiple filter on powershell azure commands

i try to get all the members users who are have account disabled in the same command.

this one works :

Get-AzureADUser -All $true -filter "(UserType eq 'Member')"

this one also works :

Get-AzureADUser -All $true -filter "(AccountEnabled eq false)"

but not this one :

Get-AzureADUser -All $true -filter {"(UserType eq 'Member')" -and "(AccountEnabled eq false)"}

so what i'm doing wrong ?



Solution 1:[1]

I would give it a try with a lighter syntax since this has to be considered as a single OData query (meaning no ````-and``` within the query which is here a mix between PS syntax and the actual command in use).

See OData queries description - which is what is used under the hood by Get-AzureADUser -filter

So in this case : Get-AzureADUser -All $true -filter "UserType eq 'Member' and AccountEnabled eq false"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jul_DW