title: PowerShell and ActiveDirectory module - Find Users that are not members of particular groups
body: <p>In the last week, I have come across PowerShell and ActiveDirectory for the first time. I would like to be able to find a list of users that aren't Admins or Domain Admins.</p>
  
  <p>So far, I know how to get all the properties for all ActiveDirectory users with the following command/statement:</p>
  
  <pre><code>Get-ADUser -Filter * -Properties *
  </code></pre>
  
  <p>What I would like to do is to print out just the usernames of current ActiveDirectory users - that are not Admins or Domain Admins.</p>
  
  <p>Here is some pseudocode/Powershell code of what I am trying to do:</p>
  
  <pre><code>$users = Get-ADUser -Filter * -Properties *
  foreach($u in $users){
      if ($u isn't an administrator OR $u isn't a domain administrator){ 
          Write-Host "User Name:" $u.Name
      }
  }
  </code></pre>
  
  <p>When I run the <code>Get-ADUser -Filter * -Properties *</code> command, I am seeing the <code>MemberOf</code> property for each user - which I'm thinking may be a clue. I have also heard of <code>AdminCount</code> from various sources found via Google (is there something called <code>DomainAdminCount</code> ?).</p>
  
  <p>I have been asked specifically to not use the PowerShell extension for ActiveDirectory - even though various sources say having this extension will make it easier.</p>
  
  <p>I have spent about 2 hours testing various combinations of statements, but my novice PowerShell status isn't helping me too much. I would be grateful for any assistance, and some clear explanations behind any feedback.</p>