I needed to write a batch file that would email some files, and could be run as a scheduled task. I chose to use Blat as my email program, you can download it for free from SourceForge.
The batch file requirements were:
I needed to write a batch file that would email some files, and could be run as a scheduled task. I chose to use Blat as my email program, you can download it for free from SourceForge.
The batch file requirements were:
Disabling a network card when running sysprepping a Windows machine is easy. Two things need to happen:
I’m finalizing a Windows 2003 R2 build that will become our gold image, which will be the source of all new server deployments within our organization. One challenge I had to overcome was getting the CD-ROM/DVD drive to be set to drive Z: after the syspreped image is cloned and booted.
Many people are familiar with changing drive letters within the Device Management tool aka devmgmt.msc. I needed to automate this task so the CD-ROM drive, which shows up as drive D on my image after running sysprep, would be automatically set to drive Z.
To accomplish this, I needed three things:
The applicable portion on my sysprep.inf file:
[GuiRunOnce]
Command0=”C:\changeletter.cmd”
My changeletter.cmd file:
diskpart /s c:\drives.txt
My drives.txt file:
select disk 0
select volume d
assign letter z noerr
Put all these pieces together, and your CD/DVD drive should be changed to drive letter Z after booting up the sysprep’ed image. Note that in the [GuiRunOnce] section of the sysprep.inf file, the part to the left of the equals sign is Command0, as is Command zero. If you wanted to run additional scripts, the next would be Command1, followed by Command2, etc.
If you’re curious about diskpart.exe, check out the details on syntax in KB300415.
Here’s a quick and easy way of checking how long a Windows server or workstation has been up, via the command line. It pipes the results of Net Statistics Workstation into find. Run the following from a command prompt:
net statistics workstation | find /i “statistics since”
The results will look like
Statistics since 8/12/2009 11:08 PM
Which shows the machine has been up since 11:08pm on August 12, 2009.
The following events were listed in the Windows 2003 event log when one of our second level help desk staff connected to the server console via RDP:
Event 1521 Source Userenv
Windows cannot locate the server copy of your roaming profile and is attempting to log you on with your local profile. Changes to the profile will not be copied to the server when you logoff. Possible causes of this error include network problems or insufficient security rights. If this problem persists, contact your network administrator.
I saved the script as getsid.vbs. Open a command prompt, and execute the script using cscript:
The script will display the SID associated with the user account specified. Delete this from:
to correct the Userenv errors.
Eric Sloof at ntpro.nl has a nice post on how to capture screen shots of virtual machine blue screens using Powershell. You can find the code here.
He then incorporated a Powershell script from Carter Shanklin that pushes a screenshot through Microsoft Office Document Imaging Library (MODI), OCR software found in Office 2003+, to extract the text from the image.
Very nice. Definitely go download his application, the Virtual Machine Blue Screen Detector. Detailed post here.
The final product, which reads out the BSOD can be found here.
Some of our administrators received the following messages when launching ConsoleOne 1.3.6f after updating to Groupwise version 7.0.3 snapins from version 6.5.5:
The procedure entry point WpSUDataLength could not be located in the dynamic link library gwenv1.dll.
and
I have an email archiving application on a Windows 2003 server that requires a lot more manual intervention than I prefer. As the application moves the mail messages throughout it’s various directory queues, sometimes it experiences an event that causes processing to halt. This results in a particular directory filling up until an administrator manually clears out the queues. The last time this happened we had 75,000 files, 10GB worth of messages we had to remove and recover by hand.
REM delete existing mailarch1file.txt file if exist mailarch1file.txt del mailarch1file.txt REM determine if files are queued using dir and output results to mailarch1file.txt e:\msw\internet\pending /A-D /B mailarch1file.txt REM If mailarch1file.txt is empty (EQU 0), files are not queued For %%R in (mailarch1file.txt) do if %%~zR EQU 0 goto nofiles REM delete existing results.txt file if exist results.txt del results.txt REM combine message file mailarch1fail.txt with results of mailarch1file.txt into results.txt copy /B mailarch1fail.txt + mailarch1file.txt results.txt REM email notification that files are queued in directory e:\msw\internet\pending REM notification to technical support using vmailer.exe that mailarch1 may be failing vmailer.exe results.txt 172.17.61.83 mailadmin@domain.corp mailarch1@domain.corp goto exitscript :nofiles REM email notification no files are queued in directory REM notification to technical support using vmailer.exe that mailarch1 is okay vmailer.exe mailarch1isok.txt 172.17.61.83 mailadmin@domain.corp mailarch1@domain.corp :exitscript REM exit script exit
If the DIR command’s output file mailarch1file.txt is empty, a notification text file mailarchisok.txt is emailed to myself that states the server is okay.
To: mailadmin@domain.corp From: mailarch1@domain.corp Subject: mailarch1 may be failing mailarch1 DOES have messages queued in the E:\MSW\Internet\PENDING directory
To: mailadmin@domain.corp From: mailarch1@domain.corp Subject: mailarch1 is okay mailarch1 DOES NOT have messages queued in the E:\MSW\Internet\PENDING directory
schtasks /create /S \\mailarch1 /U service@domain.corp /P $3rv1c3 /SC Daily /TN chksize4pm /TR c:\chksize.cmd /ST 16:00
I performed a Groupwise 6.5 to 7.0.3 upgrade this weekend on the domain and post office servers, and wrote a quick script to backup the agent configuration files. It’s not a pretty script, but I wrote it in about 10 minutes and it worked on all my Netware servers. I call this script part I since it only deals with files affected by my upgrade, which are all located on the sys volume. I upgrade the gateways in two weeks, so I’ll backup the configuration files in the domain directories then.
You need to set SERVERNAME, SERVERVOL, BKUPLOC and BKUPDIR. If I’ve missed any files, please let me know and I’ll add them to the list.
@echo off REM script to backup Groupwise configuration files from Netware server REM replace SERVERNAME with the name of your Netware/Groupwise server SET SERVERNAME=\\grpwise4 SET SYSVOL=sys REM replace SERVERVOL with the name of the volume to write the backup files to SET SERVERVOL=vol1 REM SERVERPATH is combination of server and volume name in \\server\vol\ format SET SERVERPATH=%SERVERNAME%\%SERVERVOL% REM SYSVOLPATH is combination of server and volume name in \\server\sys\ format SET SYSVOLPATH=%SERVERNAME%\%SYSVOL% REM APACHEAPTH is sys:\apache2 Apache2 web server directory SET APACHEPATH=%SERVERNAME%\%SYSVOL%\Apache2 REM NOVELLPATH is sys:\novell directory SET NOVELLPATH=%SERVERNAME%\%SYSVOL%\Novell REM TOMCATPATH is sys:\tomcat\4 directory SET TOMCATPATH=%SERVERNAME%\%SYSVOL%\tomcat\4 REM BKUPLOC is the directory to save backup files to REM this script has no error checking, so the directory's existance will probably matter SET BKUPLOC=gw65bkup REM BKUPDIR is the full path to the backup directory SET BKUPDIR=%serverpath%\%bkuploc% REM Create the backup directory md %bkupdir% REM copy sys:\system\ config files md %bkupdir%\system copy %sysvolpath%\system\*.mta %bkupdir%\system copy %sysvolpath%\system\*.poa %bkupdir%\system copy %sysvolpath%\system\*.waa %bkupdir%\system copy %sysvolpath%\system\*.cfg %bkupdir%\system copy %sysvolpath%\system\*.ncf %bkupdir%\system copy %sysvolpath%\system\*.xml %bkupdir%\system copy %sysvolpath%\system\*.bin %bkupdir%\system copy %sysvolpath%\system\autoexec.ncf %bkupdir%\system REM copy important Apache files md %bkupdir%\apache2\conf copy %apachepath%\conf\*.* %bkupdir%\apache2\conf REM copy important Tomcat files md %bkupdir%\tomcat\4\conf copy %tomcatpath%\conf\*.* %bkupdir%\tomcat\4\conf REM copy important Webaccess files md %bkupdir%\novell\webaccess\conf copy %novellpath%\webaccess\*.* %bkupdir%\novell\webaccess REM copy important Groupwise NLMs from sys:\system copy %sysvolpath%\system\dbcopy.nlm %bkupdir%\system copy %sysvolpath%\system\ex*.nlm %bkupdir%\system copy %sysvolpath%\system\gw*.nlm %bkupdir%\system copy %sysvolpath%\system\ldap*.nlm %bkupdir%\system copy %sysvolpath%\system\tsa*.nlm %bkupdir%\system copy %sysvolpath%\system\scc*.nlm %bkupdir%\system copy %sysvolpath%\system\vs*.nlm %bkupdir%\system copy %sysvolpath%\system\wvc*.nlm %bkupdir%\system copy %sysvolpath%\system\xg*.nlm %bkupdir%\system
I’m about to upgrade our Groupwise infrastructure, and I wanted to write a simple script that would backup and archive important Groupwise configuration files. I’m not proficient at scripting, but here’s what I came up with. Please recommend additional files to include if I have overlooked anything.
#################################### ### Begin gwbkup.sh ### script to backup Groupwise configuration files ### /home/backups/gw7cfg is the directory to backup files to ### backup Groupwise agent configuration files cp /opt/novell/groupwise/agents/share/* /home/backups/gw7cfg/ cp /etc/opt/novell/groupwise/gwha.conf /home/backups/gw7cfg/ ### backup Apache web server configuration files cp /etc/apache2/httpd.conf /home/backups/gw7cfg/ cp /etc/apache2/conf.d/gw* /home/backups/gw7cfg/ ### Backup WebAccess configuration files cp /opt/novell/groupwise/webaccess/webacc.cfg /home/backups/gw7cfg/ cp /opt/novell/groupwise/webaccess/commgr.cfg /home/backups/gw7cfg/commgr.cfg.webacc cp /opt/novell/groupwise/webaccess/spellchk.cfg /home/backups/gw7cfg/ ### Backup WebPublisher configuration files cp /opt/novell/groupwise/webpublisher/webpub.cfg /home/backups/gw7cfg/ cp /opt/novell/groupwise/webpublisher/commgr.cfg /home/backups/gw7cfg/commgr.cfg.webpub cp /opt/novell/groupwise/webaccess/ldap.cfg /home/backups/gw7cfg/ ### Backup Tomcat configuration files cp -r /etc/tomcat5/base/* /home/backups/gw7cfg/ ### backup gwia files specific to each gateway ### may have more than one gwia per Groupwise system, so append gateway ### name to end of file cp /mail/gwiado/wpgate/gwia703/exepath.cfg /home/backups/gw7cfg/exepath.cfg.gwia703 cp /mail/gwiado/wpgate/gwia703/gwac.db /home/backups/gw7cfg/gwac.db.gwia703 cp /mail/gwiado/wpgate/gwia703/gwauth.cfg /home/backups/gw7cfg/gwauth.cfg.gwia703 cp /mail/gwiado/wpgate/gwia703/mimetype.cfg /home/backups/gw7cfg/mimetype.cfg.gwia703 ### backup webaccess files specific to each gateway ### may have more than one gwia per Groupwise system, so append gateway ### name to end of file cp /mail/webdo/wpgate/webac703/comint.cfg /home/backups/gw7cfg/comint.cfg.webac703 cp /mail/webdo/wpgate/webac703/commgr.cfg /home/backups/gw7cfg/commgr.cfg.webac703 cp /mail/webdo/wpgate/webac703/gwac.db /home/backups/gw7cfg/gwac.db.webac703 cp /mail/webdo/wpgate/webac703/mimetype.cfg /home/backups/gw7cfg/mimetype.cfg.webac703 ### Backup Groupwise monitor files cp /opt/novell/groupwise/gwmonitor/gwmonitor.cfg /home/backups/gw7cfg/gwmonitor.cfg cp /opt/novell/groupwise/gwmonitor/default/gwmonitor.cfg /home/backups/gw7cfg/gwmonitor.cfg.default cp /opt/novell/groupwise/gwmonitor/default/gwmonitor.xml /home/backups/gw7cfg/gwmonitor.xml ### tar configuration files and label archive with today's date tar -pcvzf /home/backups/$(date +%m-%d-%Y).tar.gz /home/backups/gw7cfg/ ### Remove old configuration files rm -r /home/backups/gw7cfg/* ### End gwbkup.sh ####################################