Hello all,
What I would like to do is use the -filter parameter of get-aduser to compare 2 attributes within the search itself, instead of having to process the differences afterwards.
So here is how I normally use -filter:
get-aduser -filter {(name -like "*") -and (displayname -like "*")} -Properties displayname | ` Foreach-object{ If($_.name -eq $_.displayname){"Match!" } }
As you can see, I have to get all the users and their properties first, and then subsequently I have to use a ForEach-Object loop to determine if there are any matches.
What I would like to do is do the comparison in the -filter parameter. Something like this:
get-aduser -filter {name -eq displayname}However, I'm not aware of any way to compare attributes within -filter, and I wonder if anyone knows of a way? Or is a subsequent loop the only way to compare?