List Computers from a Group which are in a specific OU


I tried this

[PS] C:\source>Get-QADGroupMember 'Friday 1AM' | Foreach-Object { Write-Host $_.Name: (Get-QADComputer $_.DN) -includedp
roperties ou}| where {$_.ou = "ou=Disabled,ou=MITS Managed Servers,dc=ad,dc=medctr,dc=ucla,dc=edu"} | Select-Object Name
, MemberOf

1. It is giving me the member of the Group "Friday 1AM" but it is not limited to the "Disabled OU"...

2. As I have several groups

Friday 1M

Friday 2AM

Tuesday 9PM


 where I would like to verify if the machine are in the "Disabled" OU How to implement this?




  • Apparently reverse way it sowkrs at least for the first group

    Get-QADComputer -SearchRoot "ou=Disabled,ou=MITS Managed Servers,dc=ad,dc=x,dc=c,dc=e" -MemberOf 'Friday 1AM'

    trying to find a way for all groups...

    Get-QADComputer -SearchRoot "ou=Disabled,ou=MITS Managed Servers,dc=ad,dc=x,dc=c,dc=e" -MemberOf 'Friday 1AM' -OR MemberOf 'Saturday 1AM'

    does not work...

    Get-QADComputer : Cannot bind parameter because parameter 'MemberOf' is specified more than once. To provide multiple v
    alues to parameters that can accept multiple values, use the array syntax. For example, "-parameter value1,value2,value
    At line:1 char:135

    [PS] C:\source>Get-QADComputer -SearchRoot "ou=Disabled,ou=MITS Managed Servers,dc=ad,dc=m,dc=u,dc=e" -MemberO
    f 'Saturday 1AM','Friday 1AM'
    [PS] C:\source>

    No return at all...

    [PS] C:\source>Get-QADComputer -SearchRoot "ou=Disabled,ou=MITS Managed Servers,dc=ad,dc=m,dc=u,dc=e" -MemberO
    f "'Saturday 1AM','Friday 1AM'"

    Get-QADComputer : Cannot resolve directory object for the given identity: ''Saturday 1AM','Friday 1AM''.
    At line:1 char:16

    Still looking




  • Hello Dom,

    Is this post for Active Roles? If so, below is the link for the Active Roles community:

    Thank you.
  • Hello,

    Thank you I found the resolution

    [PS] C:\source>Get-QADComputer -SearchRoot "ou=Disabled,ou=MITS Managed Servers,dc=ad" -Include
    dProperties 'MemberOf' | Where-Object{$_.MemberOf -match 'Friday 1AM|Friday 2AM|Friday 2AM 2012|Friday 3AM|Friday 3AM 20
    12|Friday 5AM|Friday 5AM 2012|Friday 5PM|Friday 8PM|Friday 8PM 2012|Manual Installations|Manual Installations (Vendor su
    pported)|MITS Servers No Patch|Monday 10AM|Monday 10AM 2012|Monday 11PM|Monday 11PM 2012|Monday 1AM|Monday 1AM 2012|Mond
    ay 4AM|Monday 4AM 2012|Monday 5AM|Monday 5AM 2012|Monday 9AM 2012|Monday 9PM|Saturday 10AM OHIA VAL|Saturday 11PM|Saturd
    ay 11PM 2012|Saturday 1AM|Saturday 1AM 2012|Saturday 1AM OHIA Prod|Saturday 1AM OHIA VAL|Saturday 1AM Testing|Saturday 6
    PM OHIA Prod|Sunday 10AM 2012|Sunday 10PM|Sunday 10PM 2012|Sunday 11AM 2012|Sunday 12AM|Sunday 12AM 2012|Sunday 1AM|Sund
    ay 1AM 2012|Sunday 2AM|Sunday 2AM 2012|Sunday 3AM|Sunday 3AM 2012|Sunday 3AM Varian Citrix|Sunday 4AM|Sunday 4AM 2012|Su
    nday 6PM OHIA Prod|Sunday 9PM|Sunday 9PM 2012|Thursday 10AM|Thursday 10AM 2012|Thursday 10PM|Thursday 10PM 2012|Thursday
    1AM|Thursday 2AM|Thursday 5AM|Thursday 5AM 2012|Thursday 7PM|Thursday 9PM|Thursday 9PM 2012|Tuesday 10PM Testing|Tuesda
    y 10PM Testing 2012|Tuesday 11PM OBIX Testing|Tuesday 11PM Testing|Tuesday 11PM Testing 2012|Tuesday 1AM|Tuesday 1AM 201
    2|Tuesday 2AM|Tuesday 3AM|Tuesday 3AM 2012|Tuesday 4AM|Tuesday 4AM 2012|Tuesday 5AM|Tuesday 5AM|Tuesday 5AM 2012|Tuesday
    7PM|Tuesday 7PM 2012|Tuesday 8PM|Tuesday 8PM 2012|Tuesday 9PM|Tuesday 9PM 2012|Tuesday 9PM OHIA Test|Tuesday 9PM Testin
    g|Wednesday 10PM|Wednesday 10PM 2012|Wednesday 1AM|Wednesday 1AM 2012|Wednesday 2AM|Wednesday 2AM 2012|Wednesday 4AM|Wed
    nesday 4AM 2012|Wednesday 5AM|Wednesday 5AM 2012|Wednesday 6AM|Wednesday 6AM 2012|Wednesday 9PM'} | Select Name,DN,@{l="
    MemberOf";e={[string]$_.memberof}} | export-csv C:\Temp\Account_In_Disabled_OU.csv

  • You can use the attribute distinguishedName /DN where {$_.DN -notmatch "ou=Disabled,"}. will exclude .