Philosophy Of Automation

Last month Jeffrey Snover had an excellent post on his Philosophy of Automation. I’d like to add my 2 cents to the discussion. This is a concept I’ve espoused my entire career. I’m always looking for ways to get more done faster with less.  I expect many of you are interested in this as well or you wouldn’t be here.

The first point I want to emphasize is that not all gains in automation are monumental. In fact, I think it’s the opposite. It is in the slow accumulation of deltas between the manual way of doing something versus the automated way where we can experience the most change. As an example, you know I’ve been re-discovering DOSKey and have started exploiting the use of aliases in PowerShell.  These keyboard shortcuts save me some typing time, especially when I mistype and spend more time yet again correcting my mistakes.  It takes me too long to find anything in the Programs menu and I don’t like desktops cluttered with shortcuts.  Again, it takes me too long to find what I want.  I’d rather be at a CMD or PowerShell prompt and type a command. Macros and aliases make this process more efficient so that I spend less time on interstitial tasks and more on real work. Over the course of a day or week, this time starts adding up.

My second point is to look for automation shortcuts everywhere.  What do you do repeatedly can be streamlined and automated? I’m always wondering what time it is. Since I have my Start Bar set to autohide and don’t have a clock in my office, this takes a few steps.  In PowerShell I modified my prompt so that it displays the current date and time.  I added this function to my personal PowerShell profile.

#my prompt
function prompt
{
$myPrompt=(get-date).ToShortDateString() + ” ” + (get-date).ToShortTimeString()+ ” PS ” +
$(get-location) + ” > “
    Write-Host ($myPrompt) -nonewline -foregroundcolor Yellow
    return ” “
}

This gives me a prompt that looks like this:

1/8/2007 10:30 AM PS S:\ >

A little thing, but it adds up.

Another example is script development.  Save your code in modular chunks so it can be re-used. If you are a PrimalScript user take advantage of snippets.  Never write the same code twice. Save it as a snippet. If you squeeze it into your budget, purchase additional snippets when available. The time you save has got to be well worth the minor cost.  Use startup shortcuts.  I have a CMD window open automatically whenever I logon. This gives me immediate access to my system through my keyboard shortcuts so I can get to work faster. Here are some other ideas, some obvious others maybe not so:

Use scheduled tasks
Use mail filtering rules
Use event log filtering
Create your own PowerShell functions and aliases
Exploit any automation or commandline features of your software
Use something other than Notepad for script development
Learn to use the NET command line NET User and NET Localgroup
Learn to use these command line tools:
    FOR
    TaskList
    TaskKill
    SC
    SchTasks

The third point about automation is selecting the right tool for the job.  This also means the right scripting technology. I’ll use the oft-repeated example about file permissions. In VBScript, don’t waste time and energy trying to get WMI to fix file permissions.  Use command line tools like CACLS and DSACLS (for Active Directory) and simply call them from your script. You can still achieve automation but you’re taking the most efficient route possible.  If I can write a batch file that gets the job done faster than I can writing a VBScript, then I’ll use the batch file. I always tell people look at the task at hand, look at what you are comfortable with and look at your possibilities. Unless there is a compelling reason not to, take the path of least resistance and move on to the next task.

My last point is that automation possibilities are always changing. Obviously.  You need to keep on top of new technologies and techniques so that when the time comes to save some time through automation you have a better idea of all your options.  This means training, books, blogs and discussion forums.  Learn what other’s are automating to simplify their lives and see if it makes sense for you. 

Automate early, automate often, automate everywhere.