Reputation: 167
I need to query AD for user who have custom extensionAttribute10 not set OR not equal to specific value. I successfuly get the users with value not equal to 100 with that command:
Get-ADUser -SearchBase "ou=OU1,ou=Users,dc=domain,dc=local" -filter 'extensionAttribute10 -ne "100"'
What should I add to get also those with the value ? I've tried diffrent ways but nothing worked.
Please help
Upvotes: 4
Views: 22465
Reputation: 1
use where-object or ? take long time
for me help
get-aduser -filter {-not(extensionAttribute15 -like "*")}
Upvotes: 0
Reputation: 157
use this
get-aduser -filter * -SearchBase "ou=OU1,ou=Users,dc=domain,dc=local"
-Properties * | ? {$_.extensionAttribute10 -eq $null -or $_.extensionAttribute10 -eq 100}
Upvotes: 1
Reputation: 40928
To get users where an attribute is not set, you'd use -notlike "*"
. Use -or
to combine that with the filter you already have:
Get-ADUser -SearchBase "ou=OU1,ou=Users,dc=domain,dc=local" -filter 'extensionAttribute10 -ne "100" -or extensionAttribute10 -notlike "*"'
Upvotes: 5