Fix: Userenv event 1521 and Userenv 1511 errors in Windows Server 2003 Application log

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.   

DETAIL – The network name cannot be found.
Event 1511 Source Userenv
Windows cannot find the local profile and is logging you on with a temporary profile. Changes you make to this profile will be lost when you log off.
The solution, as outlined in KB941339, is to delete the SID entries for the source user account from the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
To determine the user’s SID, save the script found at
as a .vbs file.  
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)
Set objAccount = objWMIService.Get _
Wscript.Echo objAccount.SID
Change the Win32_UserAccount.Name=’kenmyer’,Domain=’fabrikam
from kenmeyer and fabrikam to the user account in question and your domain name.

I saved the script as getsid.vbs.  Open a command prompt, and execute the script using cscript:

cscript.exe getsid.vbs

The script will display the SID associated with the user account specified.  Delete this from:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

to correct the Userenv errors.

Capturing Virtual Machine Blue Screens via Powershell

Eric Sloof at 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.

Fix for ConsoleOne.exe error – The procedure entry point WpSUDataLength could not be located in the dynamic link library gwenv1.dll

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.   


An error occuring during ConsoleOne Startup.  ERROR:  java.lang.UnsatisfiedLinkError: ititIDs


The fix was to  copy gwenv1.dll from the Groupwise 7.0.3 client’s software distribution directory’s \win32\system32 directory to the local administrator’s c:\novell\consoleone\1.2\bin directory.
You must ensure gwenv1.dll file is version 7.0.3.  Also check c:\windows\system32 for existence of prior version of gwenv1.dll.


You can read about other gwenv1.dll issues I encountered that deal with the Groupwise client and Blackberry Enterprise Server (BES).

.cmd script that determines if a directory is empty and sends email notification of status

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.

This server is only monitored by SolarWinds, which has the ability to monitor a volume, by not a particular directory.  In the past the only time we knew there was a problem was when the volume filled up with backlogged messages.
I decided to implement a system that would periodically poll the queue directory and would send email notifications that the queue was empty, or that files were backlogged.  Because of our strict change control procedures I am unable to load any freeware monitoring solutions, so I needed to create my own via scripts.  Luckily V-Mailer, a freeware SMTP batch mailer is already approved for usage on our internal network, so I was able to utilize this software.
The script shown below, chksize.cmd, utilizes the built in DIR command to determine if the server’s e:\msw\internet\pending directory is empty.  
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 mailadmin@domain.corp mailarch1@domain.corp
goto exitscript

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 mailadmin@domain.corp mailarch1@domain.corp

REM exit script

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.   

If the output file is not empty, the results of mailarch1file.txt is concatenated with a text file mailarchfail.txt that states the server may be failing.  Because V-Mailer does not really handle attachments, I have to combine the results text file with the notification text file into results.txt, which is an ugly but effective method.
Here is my mailarch1fail.txt file, which is pre-formatted for use with V-Mailer
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
Here is my mailarch1isok.txt file, which is pre-formatted for use with V-Mailer
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

Finally, I used the Windows schtasks command line utiliy to run c:\chksize.cmd daily at 4pm.  The task, named chksize4pm runs as as the service@domain.corp user with a password of 3rv1c3. 
This is a single command that may have wrapped in your browser.
schtasks /create /S \\mailarch1 /U service@domain.corp /P $3rv1c3 /SC Daily /TN chksize4pm /TR c:\chksize.cmd /ST 16:00

Script to backup Groupwise configuration files on Netware Part I

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
REM replace SERVERVOL with the name of the volume to write the backup files to
REM SERVERPATH is combination of server and volume name in \\server\vol\ format
REM SYSVOLPATH is combination of server and volume name in \\server\sys\ format
REM APACHEAPTH is sys:\apache2 Apache2 web server directory
REM NOVELLPATH is sys:\novell directory
REM TOMCATPATH is sys:\tomcat\4 directory
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
Save the script as gwbkup1.bat and run it from your Windows workstation.

Simple script to backup Groupwise 7 configuration files on SLES Linux

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
### 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 ####################################

Powershell script to change from static to dynamic IP addressing

I’ve been working on validating an email server migration plan which has required utilizing test servers isolated from the production network.  Because they are offnet, I have to frequently switch my laptop from the production to test networks, which involves reconfiguring my network card from dynamic to static IP addresses.

I could use Windows XP’s alternate IP addressing capability to change IP addresses, but I find it takes several minutes for XP to make the automatic changeover.  I wanted to create a configuration script that would make the desired changes so that I could save shortcuts to those scripts on my desktop, which would allow for quick NIC setting modifications.

I originally tried to use the netsh command to specify NIC settings, but despite all the example syntax I found online, I was only able to get the static to dynamic changes to work, not the dynamic to static.

I finally decided to use Powershell to make these changes.  I found the following scripts at PowerShell Pro and modified them ever so slightly for my own use.

### set static IP addressing – save as setstatic.ps1
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration `
| where{$_.IPEnabled -eq “TRUE”}
Foreach($NIC in $NICs) {
  $NIC.EnableStatic(“”, “”)
  $DNSServers = “”,”″

### set dynamic addressing – save as setdynamic.ps1
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration `
| where{$_.IPEnabled -eq “TRUE”}
Foreach($NIC in $NICs) {

I then created shortcuts to the two .ps1 files using the following targets:

%windir%\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\setdynamic.ps1

%windir%\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\setstatic.ps1

I saved each shortcut to my desktop, and now I can switch IP addresses in about 15 seconds.