Saturday, January 24, 2009

Up or Down?

Here is a simple way to see if a computer is alive and well from a CMD script:
SETLOCAL ENABLEEXTENSIONS
FOR /F "skip=1 tokens=6" %%t IN ('ping -n 2 %1 ^|find /i "TTL"') DO SET targetstatus=%%t
IF "%targetstatus%"=="" GOTO down
REM Do Stuff and finish

GOTO :EOF

:down
REM Complain or do other stuff and finish

GOTO :EOF

Sunday, January 18, 2009

Logfile Maintenance

Keep logfile sprawl on your servers in check with the below script. A bit of a hack; it could likely use some cleanup. Customize the aFolders array for a list of directories to recurse. Customize sFilePattern as a regular expression to match the logfiles you see on your servers.

The script accepts an argument for the number of days. Any matching files that are older than this number of days are targets for deletion.

As with all file deletion scripts, the potential for danger is high. Use the 2nd argument of TEST to be sure of the intended results.

I install the script as a scheduled task on our servers, wrapped in a CMD file. It even updates itself at each run from Amazon AWS. More on that later.


PurgeLogs.vbs.txt

Saturday, January 17, 2009

Utilities Worth Distributing

The smaller the footprint across all desktops, the better. Every administrator has a toolbox that is reached into often. Like most, I've grabbed many from Sysinternals, with psexec being toward the top of the list.

But what bare essentials are worth distributing on all desktops? For me, it's a short list:
  • NirCmd, from the excellent Nir Sofer. You can't lose with any of the free utilities on his site.
  • BgInfo, from Sysinternals/Microsoft. Display the right information on their desktop and your users can help you help them.
  • System Scripting Runtime from Franz Krainer. This long-time favorite ActiveX provides great utility to your logon scripts.

Welcome!

Do you remember DOS and simple batch files? If you are like me, you enjoyed the challenge of finding new ways to get the most out of those commands with a minimal footprint. The key was to rely on as few external programs as possible; using what was sure to be already on the target PC.

Windows CMD files came along and some of us salivated. Command Extensions put it over the top, allowing one to hone their craft.

Then VBScript. Yes, I know. Far more extensible; more powerful. And I have not even touched PowerShell yet!

Login scripts, CMD files, VBScript utilities. Harnessing Active Directory, LDAP, and more. Using utilities that are practical to install and depend on across the enterprise.

Here I hope to share with you scripts from simple timesavers to essentials for I.T. support. Stay in your seat! You can effectively manage the enterprise desktops from the comfort of your chair.