title: Query AD for SID using PowerShell
body: <p>I need to write a PowerShell script that queries the Active Directory for the SID/GUID of certain objects and finds the least available SID/GUID within a range.</p>
  
  <p>I want to take the approach of querying the AD at once and populating an array with all SIDs and then sorting this array in increasing order. Then I'll initialize a variable with the lower limit of my SID range and compare with the array.</p>
  
  <p>Now I have 2 questions:</p>
  
  <ol>
  <li><p>How can I query the AD for all Objects and populate an array of SIDs from there?</p></li>
  <li><p>How do I compare two SID values (they are in a very complex format)?</p></li>
  </ol>
  
  <p>Thanks!</p>