Help! Please! Storing Event Logs

Discussion in 'Scripting' started by Amber, Jul 7, 2003.

  1. Amber

    Amber Guest

    I've created a script to backup/clear my event logs on
    multiple servers. This works ok, but when I attempt to
    save them on a share, it doesn't work. It will only dump
    the logs for the server that the share exists on.

    For Each objLogfile in colLogFiles
    \e$\Scripts\Application\" & strBackupName & _

    Can someone tell me what I'm doing wrong? I don't want to
    create another script just to copy these to a share, I'd
    like to incorporate it. I'd appreciate any advice.
    Especially since my last post was COMPLETELY ignored! ;-)
    Amber, Jul 7, 2003
    1. Advertisements

  2. Amber

    B-rad Guest

    This will save the event log to the C drive of the local
    machine. And then you could use
    Scripting.filesystemobject to move the file from the loca
    machine to a network share. Also this puts the date in
    the file name so that you can know when the event was
    backed up:

    MyTime = DatePart("d", now) & "_" & DatePart("m", now)
    & "_" & DatePart("yyyy", now)
    strQuery = "Select * from Win32_NTEventLogFile Where
    LogFileName='" & logger & "'"
    Set objWMIService = GetObject("winmgmts:
    {impersonationLevel=impersonate, (Backup, Security)}!\\"
    & strPC & "\root\cimv2")

    Set colLogFiles = objWMIService.ExecQuery(strQuery)

    for each objLogFile in colLogFiles
    strBackupLog = objLogFile.BackupEventLog("c:\" &
    objLogFile.LogFileName & MyTime & ".evt")

    If errBackupLog <> 0 Then
    Wscript.Echo "An error has occurred " &

    wscript.echo "Log file has been backed up and cleared"

    End If
    B-rad, Jul 8, 2003
    1. Advertisements

  3. Amber

    petal Guest

    "In addition, you must make backups to the local computer; you cannot save a
    backup of the event logs on Computer A to Computer B. Backups are
    implemented by using the LocalSystem account, which does not have the
    network credentials necessary to access remote computers. If you want to
    save backups to a central repository, modify the script to first perform the
    backup, and then move the backup file to the central repository."

    petal, Jul 8, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.