Unleashing the power of PowerShell

A primer on how Microsoft's command-line interface can help Windows admins better manage, well, just about anything

Most assuredly you've heard of PowerShell. But perhaps you haven't had the chance to see it in action. In fact, you might not even quite grasp what it is, exactly. Is it an entire scripting language? A replacement for VBScript? Today, I'm going to crack open PowerShell and reveal what it's all about.

Primarily PowerShell is a CLI shell aimed at helping Windows admins better manage, well, just about anything, from Active Directory to Exchange to third-party apps. It's available for free download for Windows XP SP2, Server 2003, and Vista; it's built in to Server 2008.

Yes, PowerShell is a CLI, not a GUI, which lets admins know right away that it's type-y, not click-y. Nevertheless, you can use PowerShell to do some incredible things without ever writing a script. It does support a powerful scripting language (although let's make it clear that it was not meant to replace VBScript). That scripting support offers admins the opportunity to put aside their point solution tools and utilize a single CLI solution.

You may ask "Why would I want to go back to a CLI when I have a GUI administration tool?" Let's compare the difference between creating an Active Directory user through the GUI and a CLI. Imagine the amount of time it takes is one minute using the GUI to create that single user. Now imagine having to create 1,000 users by repeating that task (assuming you haven't taken other steps to script the process). Don Jones, author of the book "PowerShell TFM" used that example this past week at the TechMentor Conference in Orlando, Fla. He went on to show that you might need to do 20 minutes of research to find the exact commands required to create the users with PowerShell -- but then you can accomplish the task in minutes once you've located the syntax. Indeed, for repetitive tasks, PowerShell is your tool.

So, how does one get started with PowerShell? Quite honestly, if you know any DOS commands from the days of old, you can begin using PowerShell instead of your CMD. All the commands (DIR, CD, IPCONFIG, and so forth) work just fine. But now you are going to want to move beyond this and begin learning the 130-plus cmdlets (as commands are called) available. The cmdlets follow a simple verb-noun structure. So, for example, if you want to create a new user, you type "new-user." To see a list of services, type "get-service." And then you can utilize the information you pull from one cmdlet and pipleline that over to another set of instructions.

Beyond the 130 cmdlets that come with PowerShell, there are extensions available that expand its capabilities, not only within the Microsoft world but to third-party vendors. For example, Exchange 2007 provides an additional 360 cmdlets. Microsoft built its System Center Virtual Machine Manager GUI on top of PowerShell. Rakesh Malhotra, the group program manager for SCVMM, said PowerShell's task-oriented cmdlets "provided a very user approachable scripting experience," according to the Windows PowerShell team blog .

You can also use PowerShell to manage a VMWare environment with Virtual Machines, ESX Host, and Virtual Center. In fact, InfoWorld's David Marshall wrote about how VMware administrators find value in Microsoft PowerShell: You can use PowerShell with Citrix Server Administration as well. And, no doubt, with time, other vendors will follow suit with PowerShell functionality built within their applications or additional extensions to PowerShell.

Now all those cmdlets might seem a bit overwhelming, and unlike a GUI, a CLI doesn't let you poke around and discover what's available to you. However, PowerShell includes some excellent help features. To find out general help information just type "help." For help with a cmdlet, you type "help 'cmdlet name'." To print out a full list of cmdlets, just type "get-command | out-printer". You can learn a lot about PowerShell in a very short time by simply going over some of the cmdlets each day.

Note: Windows PowerShell Help Tool from PrimalScript is a great free tool that provides you with a more convenient method of looking at detailed help about cmdlets from a separate window.

Let me know if PowerShell packs the power you need with a good old-fashioned type-y, not click-y interface.

Copyright © 2008 IDG Communications, Inc.