Powershell Get-QADUser Where-Object Help

by daytime10 at 2012-12-17 11:16:54


I am using Quest AD Cmdlets to do some searches but the results dont make sense, anyone see anything wrong with this code?

Get-QADUser -enabled -SizeLimit 0 -IncludedProperties samaccountname,extensionattribute10,extensionattribute12 | Where-Object {$.extensionattribute10 -like $searchdate -and $.extensionattribute12 -eq "B" -or $.extensionattribute12 -eq "D" -or $.extensionattribute12 -eq "F" -or $.extensionattribute12 -eq "H" } | Foreach-Object{$names += $.samaccountname}

Basically I want to search for accounts that have an extensionattribute10 equal to something AND any of the following conditions for extensionattribute12

by coderaven at 2012-12-17 11:54:30
It looks like your -ORs need to be in () so that they are calculated in addition to the $searchdate
Where-Object {$.extensionattribute10 -like $searchdate -and ($.extensionattribute12 -eq "B" -or $.extensionattribute12 -eq "D" -or $.extensionattribute12 -eq "F" -or $_.extensionattribute12 -eq "H" )}
Thats just my guess
by daytime10 at 2012-12-17 12:56:10
Your guess was correct