Below script works fine. How can I filter only the unique departments in the domain? Departments are repeated because many users can be member of the same department. I am looking for a list of all non-repeated departments in the domain.
Get-ADUser -Filter * -SearchBase "OU=Users,...,DC=COM" -Properties * | Select-Object Company, department | Export-Csv "C:\powerShell\export.csv"