title: Powershell / dsquery Pull list of users in an array of groups make an array with the unique users
body: <p>I have been tasked with making sure all admins have the correct permissions. We have a few admin groups so what I though I would do is use powershell and dsquery to pull all the users from these groups and put them in to an array. The user might be in more then one admin groupd so I only want one of each user. I would then use dsget to get more info on all users and output this to a css. Im stuck on the the fact that I cant get -contains to work right. After I have this list of users the reast should be strait forward.</p>
  
  <pre><code>$admingroups = @("Group 1","Group 2","Group 3","Group 4")
  $adminnames = @()
  
  foreach ($adming in $admingroups) { 
    $admin = (&amp;dsquery group -samid $adming -limit 0 | dsget group -members -expand)
    if ($adminnames -contains $admin) {
      write-host "Dupes"
    }Else{
      $adminnames += $admin
    }
  }
  </code></pre>