Welcome to the ScriptVault, where ScriptingAnswers.com users share their administrative scripts.

Have you written a script that accomplishes some administrative task? Please share it! Just navigate to the appropriate category and click the "Contribute to this category" link!

You are here: Top > Event Logs and Logging

Contribute to this category


Sub-Categories

(no categories are available)

 

Scripts

.vbs script to back up event logs and schedule future backups Contributed by Jeff Gilbert
This script performs a backup of the event logs and clears them. It also copies another .vbs file to the C:\ of the system running the script to schedule future event log backups to run three times a week at 10pm. So it's really two scripts in one for you here...the 2nd script needs to be in the same folder as the first script so it will be copied to the other machine correctly.
Check for BSOD errors Contributed by donj
Here's quick WMI script that demonstrates how to query specific events from a remote event log. In this case, the script generates a report of Blue Screen of Death (BSOD) crashes that the server has experienced. You could also modify this script to use my run-script-against-multiple-computers sample, to run this script against a list of servers and report on them all.
Clear Event Log Contributed by Mark Fairpo
This script silently clears or purges the Windows Event Log files. Its command-line options are the names of each event log to clear. Default is Application, Security and System.
Create Your Own Event Log Contributed by Shane Boudreaux
This script will create a customized Event Log. When the script runs, simply enter the name for teh new Event Log when prompted. I created this script and rolled it out to my clients via group policy. The Event Log i created was named "Scripts", which i use to log output from scripts i roll to my clients. It's a great place to centralize what's going on with my scripts. In fact, i've another script that will query my customized Event Log for information (ie errors, etc). Please look for it in the Vault.
Dump Security Log Contributed by Don Jones
This simple script will contact multiple computers (listed in computers.txt input file), archive their security event log to your local computer, and then clear the log.
Enumerate Logs on Servers Contributed by droopy
As a systems admin, one of the most critical, yet time consuming aspects of your daily job is to view and parse out the Event Logs on your various servers. This script will query AD for specific OS captions, query the selected machines and then write the eventlogs to an Excel spreadsheet. Please feel free to let me know if you have any questions/comments/troubles with this script. I've pasted the core code below, but if you want a formatted version, you can see it at http://www.mcttraining.com/scripting/EventLogs.htm
Event Log Back-up Contributed by David Moore
This script will compare the size of each log file to it''s maximum size. If it is greater than a certain percent (default is 80%) then it will save and clear the log file(s). This can be run manually or better yet as a scheduled task. It saves a record of the action taken to a text file.
Reporting logs from GuildFTP Contributed by Tracy Roberts
This script uses Logparser to query a directory containing GuildFTPd server logs and provides totals for Bytes uploaded and downloaded in an Excel spreadsheet with collapsible subtotals and formatting. I have based this code on ideas taken from Stephan Onisick''s article at 15 Seconds "Using an ADO Standalone/Custom Recordset in VBScript" and from various articles by The Scripting Guys. This script needs to be in the same directory as the log files or modify the script to allow for a path to be included to the SELECT statement.
Security Log Archiver Contributed by Don Jones
Log Hunter is a VBScript written in WSF format, meaning it can be used as a command-line tool and supports /? functionality.
Use MS Logparser to collect event logs from other servers Contributed by Greg Onstot
You have to install Log Parser, and register the .dl, on the computer running this script. See logparser.com. You need to list the names of the servers whose logs you want to collect in a text file (c:\scripts\logservers.txt, one servername per line. It collects the logs for the past 24 hours, and uses the checkpoint feature of logparser to note it's location in each server's logs for the next run. It doesn't include the security log, as that should be read in closer to real time, and Microsoft keeps talking about releasing ACS (formerly MACS) to handle that soon... I'll be making a second script to parse all the combined logs to a more readable format...soon. =)
Using a function to create your logs for you Contributed by Marshall
I've written this small script to promote the use of logs. Trust me when I say that logging will make your life easier! WSH doesn't exaclty offer a whole slew of easy to use tools for us to debug our own scripts, we're pretty much on our own to track our programming movements and that's where logging comes in. If you're like me you don't just write scripts for yourself. You're the scripting guy, everybody can depend on you to help them out and create solutions to their everyday woes. We work our WSH magic with our VB mojo and make everybody's life a little easier. Lets face it, we're awesome people. Despite our dillusions of God-hood, however, sometimes we make mistakes. What worked in our test environment may not always work when exposed to the read deal and we may find ourselves troubleshooting our scripts when we least expect it. That can be a hideous nightmare or it can be a cinche, if you've generated a log! This example demonstrates an easy, straight forward approach to generating a log through the use of a function. I put this function in virtually every script I write and log all the important goodies so that development and post-development debugging can be made a bit easier.
Web page event log viewer Contributed by Don Jones
This is designed to be run under IIS, and the page's security should be set to only allow Domain Admins to view the page. IIS must be set to not allow anonymous access to the page (thereby forcing authentication through the browser).