System Administration Scripts

I have written many scripts, including Windows and Netware login scripts, Windows shell scripts, PERL scripts, and very concise programs written in C, C++ and VB that would better be classified as scripts.  Nowadays I use VBScript, Windows Scripting Host, and WMI for almost everything.  Here are several little hacks that I have done.  I hope to have time to include some useful subroutines and functions in the future.

TestDomainControllers.vbs Wouldn't it be nice to have the time once a week to run the diagnostic and review the results? (yeah, right)  Well,  I wrote a script to automate that process. It works like this: First there is a subroutine that enumerates the DCs and puts the result into an array of strings. Next there is a function that runs DCDiag against the list of DCs looking for the string "failure". If that string is found it cocatenates the server name and failure string to a global string variable. At the end of this function, if a failure was found, the function returns "True". If the function returns true, the script e-mails an alert with the necessary information.
 
ProcessWatchdog.vbs This script is used to terminate a hung or long-running process. You can configure the process name, the maximum run time, notification options, and' logging options.  'Note: This script is designed to loop continuously. I was careful to ensure that destructors were included in all the correct places to eliminate memory leaks.  Normally I trigger this via a Task Scheduler job that runs at startup.
BulkCreateUsers Quick & dirty user creation script. Parses tab separated text file containing user IDs & Full Names
CleanFiles I like to use this in conjunction with the Windows Task Scheduler to automatically delete old log files, temp riles, etc.
CheckSQLStorage This is used to check the amount of storage available within a MSSQL database file.  It logs the statistics to a file.  If the amount of available storage drops below a specified threshold, an e-mail alert is sent.  This script uses the SQL-DMO API.
   
   
   
   

Note: These scripts come with no warranty whatsoever.  Always try them in a test environment prior to putting to work in production.  Use them at your own risk.