Skip to content

Instantly share code, notes, and snippets.

@at0dd
Created November 24, 2016 02:52
Show Gist options
  • Save at0dd/608c394180a8c89471a7c06215fdac24 to your computer and use it in GitHub Desktop.
Save at0dd/608c394180a8c89471a7c06215fdac24 to your computer and use it in GitHub Desktop.
Exports information from Active Directory
#Exports all computers from Active Directory to a CSV file on your desktop.
Import-Module ActiveDirectory
Get-ADComputer -Filter * -Property * | Export-CSV "$env:userprofile\Desktop\Computers.csv" -NoTypeInformation -Encoding UTF8
#Exports all groups from Active Directory to a CSV file on your desktop.
Import-Module ActiveDirectory
Get-ADGroup -Filter * -Properties * | Export-CSV "$env:userprofile\Desktop\Groups.csv" -NoTypeInformation -Encoding UTF8
#Exports all users from Active Directory to a CSV file on your desktop.
#Add "| Where-Object {$_.DistinguishedName -notlike "*CN=CN Name,DC=comp,DC=company,DC=com"}" before "| Export-CSV" to filter out an OU.
Import-Module ActiveDirectory
Get-ADUser -Filter * -Properties * | Export-CSV "$env:userprofile\Desktop\Users.csv" -NoTypeInformation -Encoding UTF8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment