Powershell Get-QADUser Where-Object Help

Welcome Forums General PowerShell Q&A Powershell Get-QADUser Where-Object Help

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

  • Author
  • #6233

    Topics: 1562
    Replies: 0
    Points: 0
    Rank: Member

    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


The topic ‘Powershell Get-QADUser Where-Object Help’ is closed to new replies.