title: How to get unique departments from active directory using Powershell?
body: <p>I would like to get a list of unique departments from Active Directory using PowerShell.</p>
  
  <p>Current code:</p>
  
  <pre><code>Import-Module activedirectory
  get-aduser -filter * -property department |select department | sort-object property -unique
  </code></pre>
  
  <p>This returns a list titled "department" with no data. How do I get a list of all Departments? </p>