I'm looking for a way to retrieve all the users that have no manager assigned to them in the active directory. Whatever I try, it always spits out errors.
Works fine:
Get-ADUser -Filter {-not(lastLogonTimeStamp -like "*")} -Properties * -SearchBase "xxx"
Doesn't work:
Get-ADUser -Filter {-not(manager -like "*")} -Properties * -SearchBase "xxx"
Get-ADUser -Filter {manager -ne "*"} -Properties * -SearchBase "xxx
Get-ADUser -Filter {manager -eq $null} -Properties * -SearchBase "xxx
Get-ADUser -Filter {manager -notlike '*'} -Properties * -SearchBase "xxx
Without using the where
clause, does anyone have an idea about the correct syntax?
Workaround:
Get-ADUser -SearchBase "xxx" -Filter * -Properties * | where {$_.manager -eq $null}
Thank you for your help guys.
Best Solution
Use
-LDAPFilter
switch: