title: Checking for users who are member in on of groups, but not in one specific group
body: <p>Im looking for a way to identify users who are member of one of few groups (a,b,c) but also are not in a specific group (d), an exception group, to later on perform some tasks on them (filling in specific attribute based on value of samaccountname).</p>
  
  <p>For now, I managed to list user accounts who are member of specific group and follow another condition of having smart card enforcement as false:</p>
  
  
  
  <pre class="lang-bsh prettyprint-override"><code>$groups = "a","b","c"
  foreach ($group in $groups) {
    Get-ADGroupMember -Identity $group |
      Get-ADUser -Properties 'smartcardlogonrequired' |
      where {$_.smartcardlogonrequired -eq $false}
  } 
  </code></pre>
  
  <p>I thought of following.
  Defining group of exceptions by</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$exceptions = (Get-ADGroup 'd').distinguishedname
  foreach ($group in $groups) {
    Get-ADGroupMember -Identity $group |
      Get-ADUser -Properties 'smartcardlogonrequired' |
      where {$_.smartcardlogonrequired -eq $false} |
      Get-ADUser –Filter {-not(memberof –eq $d}
  }
  </code></pre>
  
  <p>However, it doesn't really do the trick, and im sure theres a better way.</p>