Powershell Get-QADUser Where-Object Help

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 9 months ago.

  • Author
    Posts
  • #6233

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

    Hey

    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

    Thanks!

    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

    Thanks!

You must be logged in to reply to this topic.