OK, I have another scripting question. Here's the scenario...

A domain of servers (probably W2K AD, but not certain; I don't have all the
details yet...). On each server, there are some files with a certain
extension created by a legacy application. No rhyme or reason as to their
location. I need to find all those files and their locations and output that
information to a text file. That part is easy enough, I think. I can do it
locally with no problem, remotely across a domain might be harder. 

Next step is to copy all those files to a central location, into a directory
structure built along the lines of \servername1, \servername2, etc., dumping
the files from each server into the directory named for the server the files
were found on. I then need to be able to log the actions taken during the
copy to a log file.

So, to sum up, here's the steps I need to perform:
1. Get list of servers in domain.
2. Find all *.(some extension) files on each of those servers, write info to
a file for each server (stored on central computer). 3. Create directory
structure based on servers listed in step 1. 4. Copy all files found in step
2 to directory structure created in step 3. 5. Write copy process to log
stored on central computer.

So far, I've been able to enumerate the computers in an OU and create a text
file with the computernames with this code:
*****
Dim objOU
Dim objFileSystem
Dim objComputernames

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objComputernames = objFileSystem.createTextFile("C:\computernames.txt",
TRUE) set objOU = GetObject("LDAP://cn=computers,dc=domain,dc=com";)
for each objChildObject in objOU
    'next line writes all computer names in OU to c:\computernames.txt
    objComputernames.WriteLine(objchildObject.Name)
    next 
Wscript.Echo "Done"
*****
That creates a text file with the following:
cn=server1
cn=server2
Etc.

My next step is to use that text file to create the directory structure.
Perhaps that's not the best way to do it? I kind of like it because it gives
me a list of all the servers as a reference that I can refer to later. I
could use an array, I guess, but I'm not sure how to work with that. What I
can't figure out is the method needed to create the folder structure from
that list. I'd like to be able to strip the cn= from each line of the text
file, then create folders with those stripped names. Once I have the
folders, I want to copy all files matching an extension (*.txt for example)
from server1 to the server1 folder that was just created. Repeat for
server2, etc... I'd also like to log the activity. Nah; I don't want much.
:-)

While I'd like to be able to build this myself, I realize that as a
scripting newbie I may be in over my head. So, if there is something out
there that does this that I can modify, that's great, but I'd also like to
be able to put together the functions myself if I can figure it out. 
So, should I read from a text file list of computers and use that as the
basis for my directory structure, or should I use an array? Once I have
either, how do I pass the name to the script to create the folders? And how
do I run this against all those servers? I'd appreciate any sample scripts,
as well as any references that will help. I want to learn to do this but I'm
pretty green at it... Thanks!


**********************
Charlie Kaiser
MCSE, CCNA
Systems Engineer
Essex Credit / Brickwalk
510 985 0975 x5083
********************** 
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to