Windows Vista Forums

Create script to gather workstation logs
  1. #1


    Sear S Guest

    Create script to gather workstation logs

    Hi,

    I have trouble putting a VB script together to gather 2 different log files
    located on c:\root of each workstation


    Thanks for your help!

    Sam




      My System SpecsSystem Spec

  2. #2


    Tom Lavedas Guest

    Re: Create script to gather workstation logs

    On May 19, 8:06*am, Sear S <Sear S...@newsgroup>
    wrote:

    > Hi,
    >
    > I have trouble putting a VB script together to gather 2 different log files
    > located on c:\root of each workstation
    >
    > Thanks for your help!
    >
    > Sam
    Show us what you have and describe the problems in some detail -
    include OS specifics and any error messages encountered. Few of us
    can/are willing to do all the work for you. Plus, that's almost
    impossible, anyway, without more knowledge of your specific working
    environment, security policies, etc.
    _____________________
    Tom Lavedas

      My System SpecsSystem Spec

  3. #3


    Sear S Guest

    RE: Create script to gather workstation logs

    Hi Tom,

    I am not very good with VB script that's why I just wondered if there was a
    script out there corresponding my needs...
    OS: Windows XP Pro
    Script function: Should be to gather some workstation log files located
    right on C root...we are talking maybe about 10 workstations max.
    I know it's too much to ask...but If there is anything out there then let me
    know

    Thanks guys

    Sam

    "Sear S" wrote:

    > Hi,
    >
    > I have trouble putting a VB script together to gather 2 different log files
    > located on c:\root of each workstation
    >
    >
    > Thanks for your help!
    >
    > Sam
    >

      My System SpecsSystem Spec

  4. #4


    Tom Lavedas Guest

    Re: Create script to gather workstation logs

    On May 19, 10:45*am, Sear S <Se...@newsgroup> wrote:

    > Hi Tom,
    >
    > I am not very good with VB script that's why I just wondered if there wasa
    > script out there corresponding my needs...
    > OS: Windows XP Pro
    > Script function: Should be to gather some workstation log files located
    > right on C root...we are talking maybe about 10 workstations max.
    > I know it's too much to ask...but If there is anything out there then letme
    > know
    >
    > Thanks guys
    >
    > Sam
    >
    > "Sear S" wrote:

    > > Hi,
    >

    > > I have trouble putting a VB script together to gather 2 different log files
    > > located on c:\root of each workstation
    >

    > > Thanks for your help!
    >

    > > Sam
    Assuming you have domain admin rights on the machines in question,
    they can be accessed through their C$ (D$, etc) shares (unless they've
    been disabled), something like this ...

    sServerNames = "server1,server2,server3,etc"
    sLogName = "ourlog.log"
    sDestination = "C:\Logs\"
    with createobject("scripting.filesystemobject")
    for each server in split(sServerNames, ",")
    sLogPath = "\\" & server & "\C$\" & sLogName
    if .fileExists(sLogPath) then
    .copyfile slogpath, sDestination & server & sLogName
    end if
    next
    end with

    This is "air code" to demonstrate the approach. I have not tested it,
    so I may have missed a fine point of syntax or such, but the general
    approach is valid. See the WSH down-loadable documentation and Script
    Center samples for more information on how to solve your problem:

    WSH 5.6 documentation download (URL all one line)
    http://www.microsoft.com/downloads/d...displaylang=en

    TechNet Script Center Sample Scripts (URL all one line)
    http://www.microsoft.com/downloads/d...a-b8814fe2da5a
    _____________________
    Tom Lavedas

      My System SpecsSystem Spec

  5. #5


    Sear S Guest

    RE: Create script to gather workstation logs

    Hi Tom,

    Thanks, however 2 questions about sdestination and slogpath
    Is Sdestination as target machine (s) destination path?
    Is sLogname path the path from where the log file that needs to be copied
    from?


    Thanks

    Sam

    "Sear S" wrote:

    > Hi,
    >
    > I have trouble putting a VB script together to gather 2 different log files
    > located on c:\root of each workstation
    >
    >
    > Thanks for your help!
    >
    > Sam
    >

      My System SpecsSystem Spec

  6. #6


    Tom Lavedas Guest

    Re: Create script to gather workstation logs

    On May 25, 1:14*pm, Sear S <Se...@newsgroup> wrote:

    > Hi Tom,
    >
    > Thanks, however 2 questions about sdestination and slogpath
    > Is Sdestination as target machine (s) destination path?
    I'm not certain what you mean be the word 'target', so I'll just try
    expanding on my intention.

    It is the place where you want the log file(s) to be copied TO. That
    is the destination for the copied files.

    > Is sLogname path the path from where the log file that needs to be copied
    > from?
    Not quite. It is the name of the log file to be copied (the
    destination name is the same, except prefaced with the name of the
    server it came from), but the actual source PATH is contained in
    sLogPath (built from the server's name and the sharepoint name).

    Finally, realize that I meant this as an example from which you could
    craft your final solution. It may or may not suit your needs as
    written. I don't have a comprehensive understanding of what your
    environment is or of what you want to accomplish, exactly.

    HTH,
    _____________________
    Tom Lavedas

      My System SpecsSystem Spec

  7. #7


    Sear S Guest

    Re: Create script to gather workstation logs

    Hi Tom,

    Ok let me explain in details what I exactly want to accomplish:

    I need a script that I can use to gather a log file from a number of
    workstations...in total 40 workstations
    The log file is located on C:\logfilename of each one of those workstations...
    I have full admin access to those PCs therefore permissions won't be an issue!
    Once I ran the script, I would like it to copy all those log files from
    those machines and put them somewhere on a shared drive for me...
    I hope that clarifies a little bit my point


    Thanks

    Sam

    ..



    "Tom Lavedas" wrote:

    > On May 25, 1:14 pm, Sear S <Se...@newsgroup> wrote:

    > > Hi Tom,
    > >
    > > Thanks, however 2 questions about sdestination and slogpath
    > > Is Sdestination as target machine (s) destination path?
    >
    > I'm not certain what you mean be the word 'target', so I'll just try
    > expanding on my intention.
    >
    > It is the place where you want the log file(s) to be copied TO. That
    > is the destination for the copied files.
    >

    > > Is sLogname path the path from where the log file that needs to be copied
    > > from?
    >
    > Not quite. It is the name of the log file to be copied (the
    > destination name is the same, except prefaced with the name of the
    > server it came from), but the actual source PATH is contained in
    > sLogPath (built from the server's name and the sharepoint name).
    >
    > Finally, realize that I meant this as an example from which you could
    > craft your final solution. It may or may not suit your needs as
    > written. I don't have a comprehensive understanding of what your
    > environment is or of what you want to accomplish, exactly.
    >
    > HTH,
    > _____________________
    > Tom Lavedas
    > .
    >

      My System SpecsSystem Spec

  8. #8


    Tom Lavedas Guest

    Re: Create script to gather workstation logs

    On May 27, 3:57*pm, Sear S <Se...@newsgroup> wrote:

    > Hi Tom,
    >
    > Ok let me explain in details what I exactly want to accomplish:
    >
    > I need a script that I can use to gather a log file from a number of
    > workstations...in total 40 workstations
    > The log file is located on C:\logfilename of each one of those workstations...
    > I have full admin access to those PCs therefore permissions won't be an issue!
    > Once I ran the script, I would like it *to copy all those log files from
    > those machines and put them somewhere on a shared drive for me...
    > I hope that clarifies a little bit my point
    >
    > Thanks
    >
    > Sam
    OK, from what you said, you just need to change the value of sLogName
    to be "logfilename" and the sDestination content to be "\
    \Storageservername\locationfoldername\" and complete the list of
    server names.

    sServerNames = "server1,server2,server3,etc"
    sLogName = "logfilename"
    sDestination = "\\Storageservername\locationfoldername\"
    with createobject("scripting.filesystemobject")
    for each server in split(sServerNames, ",")
    sLogPath = "\\" & server & "\C$\" & sLogName
    if .fileExists(sLogPath) then
    .copyfile slogpath, sDestination & server & sLogName
    end if
    next
    end with

    Of course, 40 server names would be a problem in the SET statement, so
    a file list (one name per line) would be better, something like
    this ...

    sServerNameFile = "c:\some\local\folder\Servernames.txt"
    sLogName = "logfilename"
    sDestination = "\\Storageservername\locationfoldername\"
    with createobject("scripting.filesystemobject")
    sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll
    for each server in split(sServerNames, vbNewLine)
    sLogPath = "\\" & server & "\C$\" & sLogName
    if .fileExists(sLogPath) then
    .copyfile slogpath, sDestination & server & "_" & sLogName
    end if
    next
    end with

    It should create one file for each server in the specified location.
    _____________________
    Tom Lavedas

      My System SpecsSystem Spec

  9. #9


    Sear S Guest

    Re: Create script to gather workstation logs

    HI Tom,

    A BIG THANK YOu this works perfectly!!
    If the file name on some servers is different than the one mentioned in the
    Slogname section then can I add more file names as below?

    sServerNameFile = "c:\some\local\folder\Servernames.txt"

    > sLogName = "logfilename,logfilename2, etc..."
    > sDestination = "\\Storageservername\locationfoldername\"
    > with createobject("scripting.filesystemobject")
    > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll
    > for each server in split(sServerNames, vbNewLine)
    > sLogPath = "\\" & server & "\C$\" & sLogName
    > if .fileExists(sLogPath) then
    > .copyfile slogpath, sDestination & server & "_" & sLogName
    > end if
    > next
    > end with








    "Tom Lavedas" wrote:

    > On May 27, 3:57 pm, Sear S <Se...@newsgroup> wrote:

    > > Hi Tom,
    > >
    > > Ok let me explain in details what I exactly want to accomplish:
    > >
    > > I need a script that I can use to gather a log file from a number of
    > > workstations...in total 40 workstations
    > > The log file is located on C:\logfilename of each one of those workstations...
    > > I have full admin access to those PCs therefore permissions won't be an issue!
    > > Once I ran the script, I would like it to copy all those log files from
    > > those machines and put them somewhere on a shared drive for me...
    > > I hope that clarifies a little bit my point
    > >
    > > Thanks
    > >
    > > Sam
    >
    > OK, from what you said, you just need to change the value of sLogName
    > to be "logfilename" and the sDestination content to be "\
    > \Storageservername\locationfoldername\" and complete the list of
    > server names.
    >
    > sServerNames = "server1,server2,server3,etc"
    > sLogName = "logfilename"
    > sDestination = "\\Storageservername\locationfoldername\"
    > with createobject("scripting.filesystemobject")
    > for each server in split(sServerNames, ",")
    > sLogPath = "\\" & server & "\C$\" & sLogName
    > if .fileExists(sLogPath) then
    > .copyfile slogpath, sDestination & server & sLogName
    > end if
    > next
    > end with
    >
    > Of course, 40 server names would be a problem in the SET statement, so
    > a file list (one name per line) would be better, something like
    > this ...
    >
    > sServerNameFile = "c:\some\local\folder\Servernames.txt"
    > sLogName = "logfilename"
    > sDestination = "\\Storageservername\locationfoldername\"
    > with createobject("scripting.filesystemobject")
    > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll
    > for each server in split(sServerNames, vbNewLine)
    > sLogPath = "\\" & server & "\C$\" & sLogName
    > if .fileExists(sLogPath) then
    > .copyfile slogpath, sDestination & server & "_" & sLogName
    > end if
    > next
    > end with
    >
    > It should create one file for each server in the specified location.
    > _____________________
    > Tom Lavedas
    > .
    >

      My System SpecsSystem Spec

  10. #10


    Tom Lavedas Guest

    Re: Create script to gather workstation logs

    On May 28, 10:30*am, Sear S <Se...@newsgroup> wrote:

    > HI Tom,
    >
    > A BIG THANK YOu this works perfectly!!
    > If the file name on some servers is different than the one mentioned in the
    > Slogname section then can I add more file names as below?
    >
    > sServerNameFile = "c:\some\local\folder\Servernames.txt"
    >

    > > sLogName = "logfilename,logfilename2, etc..."
    > > sDestination = "\\Storageservername\locationfoldername\"
    > > with createobject("scripting.filesystemobject")
    > > * sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll
    > > * for each server in split(sServerNames, vbNewLine)
    > > * * sLogPath = "\\" & server & "\C$\" & sLogName
    > > * * if .fileExists(sLogPath) then
    > > * * * .copyfile slogpath, sDestination & server & "_" & sLogName
    > > * * end if
    > > * next
    > > end with
    > "Tom Lavedas" wrote:

    > > On May 27, 3:57 pm, Sear S <Se...@newsgroup> wrote:

    > > > Hi Tom,
    >

    > > > Ok let me explain in details what I exactly want to accomplish:
    >

    > > > I need a script that I can use to gather a log file from a number of
    > > > workstations...in total 40 workstations
    > > > The log file is located on C:\logfilename of each one of those workstations...
    > > > I have full admin access to those PCs therefore permissions won't be an issue!
    > > > Once I ran the script, I would like it *to copy all those log filesfrom
    > > > those machines and put them somewhere on a shared drive for me...
    > > > I hope that clarifies a little bit my point
    >

    > > > Thanks
    >

    > > > Sam
    >

    > > OK, from what you said, you just need to change the value of sLogName
    > > to be "logfilename" and the sDestination content to be "\
    > > \Storageservername\locationfoldername\" and complete the list of
    > > server names.
    >

    > > sServerNames = "server1,server2,server3,etc"
    > > sLogName = "logfilename"
    > > sDestination = "\\Storageservername\locationfoldername\"
    > > with createobject("scripting.filesystemobject")
    > > * for each server in split(sServerNames, ",")
    > > * * sLogPath = "\\" & server & "\C$\" & sLogName
    > > * * if .fileExists(sLogPath) then
    > > * * * .copyfile slogpath, sDestination & server & sLogName
    > > * * end if
    > > * next
    > > end with
    >

    > > Of course, 40 server names would be a problem in the SET statement, so
    > > a file list (one name per line) would be better, something like
    > > this ...
    >

    > > sServerNameFile = "c:\some\local\folder\Servernames.txt"
    > > sLogName = "logfilename"
    > > sDestination = "\\Storageservername\locationfoldername\"
    > > with createobject("scripting.filesystemobject")
    > > * sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll
    > > * for each server in split(sServerNames, vbNewLine)
    > > * * sLogPath = "\\" & server & "\C$\" & sLogName
    > > * * if .fileExists(sLogPath) then
    > > * * * .copyfile slogpath, sDestination & server & "_" & sLogName
    > > * * end if
    > > * next
    > > end with
    >

    > > It should create one file for each server in the specified location.
    > > _____________________
    > > Tom Lavedas
    > > .
    If there are just a few differences, that could be handled as Select
    Case in place of the simpler "IF .FileExists(...)" statement,
    something like this ...

    Select Case True
    case .fileExists(sLogPath1)
    .copyfile slogpath, sDestination & server & sLogName1
    case .fileExists(sLogPath2)
    .copyfile slogpath, sDestination & server & sLogName2
    case .fileExists(sLogPath3)
    .copyfile slogpath, sDestination & server & sLogName3
    end if

    Of course, the three file name variables would need to be defined
    earlier in the script.

    If there are many different names, it might be easier to add them as
    part of the ServerNames text file, on lofgilename per server, as
    in ...

    server1, logfilename.log
    server2 anothername.txt
    server3
    etc.

    To simplify things a bit, a blank for the name could be used to
    indicate the use of a default name. Then the code might look like
    this ...

    sServerNameFile = "c:\some\local\folder\Servernames.txt"
    sDefaultLogName = "logfilename"
    sDestination = "\\Storageservername\locationfoldername\"
    with createobject("scripting.filesystemobject")
    sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll
    for each sLine in split(sServerNames, vbNewLine)
    sLine = trim(sLine)
    if not (sLine) = "" then
    aTemp = split(sLine & " " & sDefaultLogName)
    server = aTemp(0)
    sLogName = aTemp(1)
    sLogPath = "\\" & server & "\C$\" & sLogName
    if .fileExists(sLogPath) then
    .copyfile slogpath, sDestination & server & "_" & sLogName
    end if
    end if
    next
    end with
    _____________________
    Tom Lavedas

      My System SpecsSystem Spec

Create script to gather workstation logs problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing VMWare Server on my XP x86 workstation. Can I create virtual x64 servers? AllenM Virtual PC 1 16 Oct 2009
Re: Looking for a script to read FTP logs BJ VB Script 1 03 Feb 2009
Re: Looking for a script to read FTP logs gimme_this_gimme_that VB Script 4 03 Feb 2009
script to report on event logs tiv VB Script 5 26 Sep 2008
create dir, stuff some logs in a new file in that dir =?Utf-8?B?R2lsIE5vdmFr?= PowerShell 3 12 Sep 2006