| |
aroberts
Posts: 2
Score: 0
Joined: 5/14/2008
Status: offline
|
Hi, I have a problem where i need to create a whole lot of OU's in the AD, down to 4 or 5 layers, read from an input file. I am able to script to level 3, but cant work out how to get further down. This is a problem as i cant create the child objects. If someone can please help me it would be greatly appreciated. I have attached the input file and script below. The third tab is the description of the OU. Andrew Example input file (save as OUStructure.txt in the script location): Root Root Finance Finance Objects Root Finance Users Finance Users Root Finance Laptops Finance Laptops Root Finance Desktops Finance Desktops Root Finance Printers Finance Printers Root Root Marketing Marketing Objects Root Marketing Users Marketing Users Root Marketing Laptops Marketing Laptops Root Marketing Desktops Marketing Desktops Root Marketing Printers Marketing Printers Root Root Administrators Administrators Objects Root Administrators Users Administrators Users Root Administrators Laptops Administrators Dektops Root Administrators Desktops Administrators Desktops ----------------------------------------------------------------------------------------------------- strInputFile = "OUStructure.txt" set objFSO = Wscript.CreateObject("scripting.filesystemobject") Set objInputFile = objFSO.OpenTextFile(strInputFile, 1) Set objNetwork = WScript.CreateObject("WScript.Network") strDomain = objNetwork.UserDomain strRoot = "DC=" & strDomain & ",DC=local" Do Until objInputFile.AtEndOfStream strLine = objInputFile.readline strLine = replace(strLine,chr(34),"") strLine = replace(strLine,",",chr(92) & ",") arrLine = split(strLine,vbTab) If (arrLine(1) = "Root") then strLDAP = "LDAP://" & strRoot set objLDAP = getobject(strLDAP) set objOU = objLDAP.create("organizationalUnit","OU=" & arrLine(2)) objOU.Put "Description", arrLine(3) objOU.Setinfo Else If (arrLine(0) = "Root") then strLDAP = "LDAP://OU=" & arrLine (1) & "," & strRoot set objLDAP = getobject(strLDAP) set objOU = objLDAP.create("organizationalUnit","OU=" & arrLine(2)) objOU.Put "Description", arrLine(3) objOU.Setinfo Else strLDAP = "LDAP://OU=" & arrLine(1) & ",OU=" & arrLine(0) & "," & strRoot set objLDAP = getobject(strLDAP) set objOU = objLDAP.create("organizationalUnit","OU=" & arrLine(2)) objOU.Put "Description", arrLine(3) objOU.Setinfo End If End If Loop wscript.echo "Complete"
< Message edited by aroberts -- 5/15/2008 12:25:45 AM >
|
|