Import AD Objects Into New Domain

Now we need to import our user objects into a new domain.

Spin up a new Windows Server 2012 R2 VM, add necessary roles for AD.

Create a new OU in AD for your imported users:
dsadd ou “OU=HWCDI,DC=HWCDI,DC=local”

Parse / modify your usersFile.ldf file however you’d like,
just ensure each object’s entry is updated with your new domain info:
dn: CN=Colin St. George,OU=HWCDI,DC=HWCDI,DC=local

Now, import that list! Similar to previous post (with help from Daan):

#importAD.ps1 – usage: powershell -f .\importAD.ps1 -mode import
[string]$mode = “default”

# Clear screen and load Active Directory module
Import-Module ActiveDirectory

# Configure these variables first, it won’t work without them!
$dcHostname = “hwcdir2dc1.hwcdi.local”
$ouDistinguishedName = “ou=hwcdi,dc=hwcdi,dc=local”
#$exportFile = “usersFile.ldf”
$importFile = “usersFile.ldf”

# What to do when the script parameter is “script.ps1 -mode import”
if($mode -eq “import”){
Write-Host ” ”
Write-Host “Importing users from ” $importFile “…”
ldifde -i -f $importFile
Write-Host ” ”

This will import your AD objects into the OU.

For my User objects, It imported them in a disabled state.

After reviewing my results, My export is not grabbing all object attributes, so it will need some tweaking.
We’ll also need some automation to enable each user account / set initial password.

Stay tuned!

Leave a Reply

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