Forum Discussion
Imadnazim
May 09, 2024Copper Contributor
Get-aduser is not working in PS7 if i am trying to filter user using attribute Whencreated.
below code is working in PS 5.1 but Not in PS 7.4.2
$when = $(Get-Date).AddDays(-3).date
$data = Get-ADUser -Filter {whenCreated -ge $When}
$data.count
Error: Get-ADObject: Error parsing query: 'whenChanged -gt 05/06/2024 00:00:00' Error Message: 'Operator Not supported: ' at position: '19'.
Hi, Vasil.
This is in relation to the on-premise ActiveDirectory module, not any Azure modules.
Your post is somewhat confusing since your example uses "-ge" yet the error reports "-gt". Even so, I've tried both under PowerShell 7.4.2 and cannot reproduce the issue.
Can you please check your example in this post is accurate?
Also, check both the module and (optionally) the command to ensure it's not coming from an alternate installation.
Verifying commandlet(s):
Verifying modules(s):
Cheers,
Lain
- You should not be using the Azure AD module, switch to the Graph SDK instead:
Get-MgUser -Filter "createdDateTime ge $([datetime]::UtcNow.AddDays(-3).ToString("s"))Z" -All:$true- LainRobertsonSilver Contributor
Hi, Vasil.
This is in relation to the on-premise ActiveDirectory module, not any Azure modules.
Your post is somewhat confusing since your example uses "-ge" yet the error reports "-gt". Even so, I've tried both under PowerShell 7.4.2 and cannot reproduce the issue.
Can you please check your example in this post is accurate?
Also, check both the module and (optionally) the command to ensure it's not coming from an alternate installation.
Verifying commandlet(s):
Verifying modules(s):
Cheers,
Lain
- ImadnazimCopper Contributor
Hello LainRobertson ,
I ran commands as suggested by you. My AD module is different that could be an issue here.