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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse AD computer names to excel sheet

Status
Not open for further replies.

Stephon98caffe

Programmer
Feb 18, 2005
25
US
My job would like me to parse a file that contains a list of computer names in the following format:
"CN=DUB13520163-L,OU=Computers,OU=ORM,DC=dva,DC=va,DC=gov"
"CN=co0828-01,OU=VHACO Laptops,OU=VHA,DC=dva,DC=va,DC=gov"

I was wondering if anyone knew a better logic of parsing this information. All I need is the CN and the 2nd OU which tells what organization the computer is in. There are about 6 different OU's and I would like to have excel spread sheet for each OU.

Thanks for your help
 
Something like this ?
strLine = "CN=co0828-01,OU=VHACO Laptops,OU=VHA,DC=dva,DC=va,DC=gov"
arTmp = Split(strLine, ",")
strCN = Mid(arTmp(0), 4)
strOU = Mid(arTmp(3), 4)


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The code you provided captures the "=". How would I take the "=" sign out
"CN=DUB13520163-L,OU=Computers,OU=ORM,DC=dva,DC=va,DC=gov"

what actually does the Mid( , ) work?

arTmp = Split(strLine, ",")
strCN = Mid(arTmp(0), 4)
strOU = Mid(arTmp(3), 4)
 
With your posted sample, unless the double-quotes are part of the string, I don't see why my code captures the = ...
Anyway you may try this:
arTmp = Split(strLine, ",")
strCN = Mid(arTmp(0), [!]5[/!])
strOU = Mid(arTmp(3), [!]5[/!])

what actually does the Mid( , ) work?
when in the VBE put the cursor inside the Mid keyword and press the F1 key.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top