Import/Export Active Directory data…

I was trying to get a test environment up and running that should reflect the production environment of my customer (off course at the customers site.. secured and all).. one task was to duplicate the OU structure, group structure and user information (without passwords).

Browsing through the web I found a VBS script that can do this, and while the export was good, the import script did not work.. The following changes have been made to the scripts (link down under).. to make the OU part of the script work..

wscript.echo “Creating OU”
   ‘Parse OUs.txt
   iOU = 0
   ReDim arrActOU(2000,3)
   Do While Not ousFile.AtEndOfStream
      strLine = ousFile.ReadLine
      arrOU = split(strLine, “,”)
      iOU = iOU + 1
      iLvl = UBound(arrOU) – 2
      If iHighLvl < iLvl then iHighLvl = iLvl
      strObject = “”
      For x = 1 to UBound(arrOU)
         If Left(arrOU(x), 3) <> “DC=” then
            strObject = strObject & arrOU(x) & “,”
         End If
      Next
      strObject = strObject & newDomainName
    �
      arrActOU(iOU, 1) = iLVL
      arrActOU(iOU, 2) = arrOU(0)
      arrActOU(iOU, 3) = strObject
      Set oOU = GetObject(“LDAP://” & strObject)
      Set oOUnew = oOU.Create(“organizationalUnit”, arrOU(0))
      oOUnew.SetInfo
      If Err <>0 Then
 wscript.echo “Error ” & Err.description
      End if �
      Set oOU = Nothing
      Set oOUnew = Nothing
  Loop
End Sub

Get the rest of these great working scripts on: http://community.spiceworks.com/scripts/show/39-ad-export  and http://community.spiceworks.com/scripts/show/40-ad-import

PS: Make sure to open the txt files and look for , entries.. they must be deleted.. else they will crash the import

Tagged