Sunday, January 12, 2020

Export AD user to csv file

Leave a Comment
This blog post is kind of immediate requirement to import users from one dev AD to another testing AD. So it include of two parts.

Part 1: To export users from Dev AD to csv file
Part 2: To import users to testing AD from csv file

In this post we will see how to export users from particular OU to a CSV file.

Following is PowerShell script which I used:

#OU Name/path whom users need to be exported
$OUName = 'ou=OUName,dc=domain,dc=com'

#Path where csv file will be created with OU users
$ExportPath = 'c:\tmp\myOU_Users.csv'

#command to export users with selected properties
Get-ADUser -Filter * -SearchBase $OUName -Properties GivenName, EmailAddress,di
splayname,Name,CN,OU,Surname,Title,sAMAccountType,samaccountname | Export-Csv $ExportPath

This will export uses from required OU to csv files
If You Enjoyed This, Take 5 Seconds To Share It

0 comments: