Skip to content

Instantly share code, notes, and snippets.

@rueedlinger
Created November 8, 2016 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rueedlinger/63c605e69a76e6e75e7c0d300b8a4321 to your computer and use it in GitHub Desktop.
Save rueedlinger/63c605e69a76e6e75e7c0d300b8a4321 to your computer and use it in GitHub Desktop.
Extract data from active directory (PowerShell)
Import-Module ActiveDirectory
$ADSearchBase = "OU=Employees,OU=Users,OU=XYZ,DC=ads,DC=XYZ,DC=com"
$OutFile = "C:\tmp\ad_export.csv"
Get-ADUser -filter * -properties GivenName,Surname,CN,Title,Department,Country,City,EmailAddress,whenCreated -SearchBase $ADSearchBase | select GivenName,Surname,CN,Title,Department,Country,City,EmailAddress,whenCreated | Export-Csv $OutFile -NoTypeInformation -Encoding "UTF8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment