get-aduser -filter * -SearchBase "OU=users,DC=domain,DC=local" -Properties department,description | Select-Object samaccountname,name,department,description,distinguishedName | export-csv outfile.csv -Encoding UTF8

 

Eller om du endast vill lista "enablade" konton.

get-aduser -filter 'enabled -eq $true' -SearchBase "OU=users,DC=domain,DC=local" -Properties department,description | Select-Object samaccountname,name,department,description,distinguishedName | export-csv outfile.csv -Encoding UTF8