script

Counting the number of files in a directory, command line style

by File in: script

I needed to count the number of files in a directory on a Windows 2003 server.  Here’s the command that can easily be scripted: dir/b/a-d c:\directory | find /v /c “::” You can also specify a file share instead of a directory name: dir/b/a-d \\server\share | find /v /c “::” If you want to count the number […]

Script to gracefully power off a VM guest

by File in: virtualization, Vmware

You can use vmware-cmd to shut down a VMware guest.  The syntax is [sourcecode language=”perl”] vmware-cmd /vmfs/volumes/datastore1/guest1/guest1.vmx stop [/sourcecode] Powering off a VM guest is often part of a larger script, so I need to know when the guest is really down before executing the remainder of my script.  The following code checks the guest’s state using […]

Script to remotely list Windows local administrator group membership

by File in: script

The following script can be run against remote Windows machines, and will enumerate the contents of the remote server’s local administrators group. It requires Sysinternals PSExec utility, and must be run with administrative credentials.  Set the four paths to the correct locations for your workstation. REM set path to PSexec on machine the script is […]

Script to find and email files in a directory

by File in: script

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:  1.  Had to email all the .xls files in one directory from the current date. […]

Howto: Disable a NIC when running Sysprep

by File in: deployment

Disabling a network card when running sysprepping a Windows machine is easy.  Two things need to happen:  1.  Add the following command to the [GuiRunOnce] section of your sysprep.inf file   Command0=”C:\temp\disablenic.cmd”   2.  On the machine you are sysprepping, create a C:\temp\disablenic.cmd file that contains the following:   netsh interface set interface “Local Area […]

Howto automatically change the CD-ROM drive letter after running sysprep

by File in: deployment

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 […]

Find Windows system uptime from the command line

by File in: Windows

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 […]

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

by File in: Windows

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 […]

Capturing Virtual Machine Blue Screens via Powershell

by File in: script

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 […]

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

by File in: Groupwise

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 An error occuring during ConsoleOne Startup.  ERROR:  java.lang.UnsatisfiedLinkError: ititIDs   The fix was to  copy gwenv1.dll from the […]