Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass line from text file and use output within script.

Status
Not open for further replies.

ccoll23

MIS
Jan 17, 2002
43
0
0
US
Have a script that reads a txt file which contains the computer's OU path. I want to take that line from the text and put that into the script to have it join the domain.

I get the error "an invalid DN syntax hs been specified.

How can I get it to read the variable "strContents" ?

here is the script"

Const FOR_READING = 1
const FOR_Writing = 2

Set objFiles=objFSO.GetFile("\\server\eXpress\NewPC\" & strComputer & ".txt")
Set objTextStream = objFSO.OpenTextFile ("\\server\eXpress\NewPC\" & strComputer & ".txt", FOR_READING)
strContents = objTextStream.Read(40)
WScript.Echo strContents
objTextStream.Close

Set objNewOU = GetObject("LDAP:// " & strContents & ",OU=ABComputers,DC=Domain,DC=net")

Set objMoveComputer = objNewOU.MoveHere _
("LDAP://CN= " & strcomputer & ",CN=Computers,DC=Domain,DC=net", "CN= " & strcomputer & "")

 
What is displayed by the following ?
Code:
WScript.Echo "'" & strContents & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The contents of the txt file which is one line and looks like this:

OU=Laptops,OU=Dcc,OU=Satelite


Thanks
 
Provided you really want this:
Set objNewOU = GetObject("LDAP://OU=Laptops,OU=Dcc,OU=Satelite,OU=ABComputers,DC=Domain,DC=net")
I'd replace this:
strContents = objTextStream.Read(40)
Set objNewOU = GetObject("LDAP:// " & strContents & ",OU=ABComputers,DC=Domain,DC=net")
with this:
strContents = objTextStream.ReadLine
Set objNewOU = GetObject("LDAP://" & strContents & ",OU=ABComputers,DC=Domain,DC=net")



Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
THANK YOU!!!!...Ive been looking at this all day..


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top