Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :
TheServerGeeks

IT with everything IT

How to Export the Active Directory User Dump to an CSV file

/

You can use the below script to export all the user’s details in the Active Directory and export to .CSV file.

 Import-module ActiveDirectory

$Filename = Read-Host "Enter the File Name You want to Export (Example : Filename You want)"
$filepath = Read-Host "Enter the path where you want to save the file"

$searchBase = (get-addomain).Distinguishedname

Get-ADUser -Filter * -SearchBase "$searchbase" -Properties * | Export-Csv $filepath

Write-host "

Exported File Can be located at $filepath

" -foreground "Green"

Run this Script on the machine where you have the Active Directory Remote administration tools installed or on the Domain controller itself.

Method 1: Copy the Script to PowerShell ISE and run.

Copy the entire script given above into the PowerShell ISE and save the file as “ExportADUser.Ps1” (Make sure you have a “Write” access to the path you specify).Run the script from ISE console.

This will create the Test.CSV file containing all the properties of all the Ad users in the directory where the PowerShell ISE is launched from. i.e. “C:\Users\%UserName%\Desktop\Test.CSV”

Method 2: Call the Script from PowerShell

Launch the PowerShell and change the directory to where the ExportADUser.Ps1 file is located. From there, call the script by typing “.\ExportADUser.Ps1”.

Later, Enter the File name and path. Depending on the AD user count, PowerShell will create the .CSV file in the given directory with all the attribute values.

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar