title: Quick query for large groups in AD
body: <p>I'd like to identify a more efficient method for identifying large AD groups with Powershell (say, more than 5000 users). Listing the members is not required, since I want to <strong>exclude</strong> these groups from another process.</p>
  
  <p>Obviously I can use <code>Get-ADGroup</code> as below, but if there's a more efficient way (e.g. by using LDAP filters, etc), that'd be helpful. </p>
  
  <pre><code>(Get-ADGroup "Group" -Properties members).members.count | where {$_ -lt 5000}
  </code></pre>
  
  <p>I'm querying members of hundreds of thousands of groups for the actual purpose, and I would like to exclude larger groups in the initial runs (since the main process becomes quite memory intensive on a large group).</p>