Home > database >  Get-PnPAzureADUser : Code: BadRequest Message: Invalid filter clause
Get-PnPAzureADUser : Code: BadRequest Message: Invalid filter clause

Time:12-21

I want to filter the Active Directory using email address which is enabled, so i tried this, but i got the below error :-

PS C:\WINDOWS\system32> $HRUser = Get-PnPAzureADUser -Filter  {AccountEnabled eq "True" and Mail eq [email protected] }
Get-PnPAzureADUser : Code: BadRequest
Message: Invalid filter clause
Inner error:
        AdditionalData:
        date: 2022-12-20T23:54:51
        request-id: 2bd6308e-3afd-46e4-afcf-2898883852a0
        client-request-id: 2bd6308e-3afd-46e4-afcf-2898883852a0
ClientRequestId: 2bd6308e-3afd-46e4-afcf-2898883852a0
At line:1 char:11
  $HRUser = Get-PnPAzureADUser -Filter  {AccountEnabled eq "True" and M ...
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      CategoryInfo          : InvalidOperation: (:) [Get-PnPAzureADUser], PSInvalidOperationException
      FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Principals.GetAzureADUser

any advice how i can filter using email and AccountEnabled ?

CodePudding user response:

I tried to reproduce the same in my environment and got below results:

When I ran the same command as you, I got same error as below:

Get-PnPAzureADUser -Filter  {AccountEnabled eq "True" and Mail eq [email protected] }

Response:

enter image description here

To resolve the error, I modified the command and got results successfully like below:

Get-PnPAzureADUser -Filter  { AccountEnabled eq true and Mail eq '[email protected]'}

Response:

enter image description here

  • Related