Creating an IT admin's PowerShell toolbox
The PowerShell scripting tool in Windows 7 and Windows Server 2008 R2 should be the staple of any IT administrator's toolbox. Learn how it can help you.
Remember when doing repetitive tasks on Windows servers meant breaking out your DOS batch-scripting skills? Or when IT administrators had to get the syntax just right for a Virtual Basic script to do what they wanted it to? I am thankful that the ways of old have been replaced with the means of new, and PowerShell is now a staple in my tool chest.
Several hardware and software manufacturers have chosen PowerShell for installation, configuration and reporting: In fact, the tool is sometimes the only means of administration for a product. Version 1 of PowerShell has been around for a while, but with the release of Version 2 in Windows Server 2008 R2 and Windows 7, it's gaining popularity as a scripting tool.
There has even been a project to create an open source implementation of PowerShell called Pash. Pash would enable scripting in other operating systems such as Linux, which could open up a new set of possibilities. While I embrace the theory behind this initiative, I find it difficult to think that Perl and Bash shell scripting could be subsidized or replaced.
On the Windows and application programming interface (API) front, PowerShell offers IT admins flexibility and power. The architecture of cmdlets and aliases, as well as many features that are in other popular scripting languages, allows many -- if not all -- of my administrative and reporting duties to be done inside the proverbial "single pane of glass." Contrary to common perception, though, the pane of glass is a command-line interface (CLI), not a graphical user interface (GUI). Many users have grown accustomed to the GUI, but I am grateful for the nostalgia of the CLI.
Now, although I prefer to use the CLI -- or Integrated Scripting Environment (ISE) -- a GUI is convenient for more elaborate editing and function creation. A good PowerShell editor should be the first thing you pick for your essential PowerShell toolbox. I use PowerGUI from Quest Software. I have also looked at other GUI editors, such as PrimalScript from Sapien and PowerShell Plus from Idera, but I prefer the community feel of PowerGUI and have had very good luck with it.
Quest sells PowerGUI Pro, which is commercial and adds some features, but not enough for me to buy. I am also a fan of the vEcoShell Initiative from Vizioncore. Scott Herold has created a fantastic .NET interface that echoes the one of PowerGUI, including the addition of PowerPacks and Libraries. When I have to get an editor running quickly without using my laptop or performing an install, I prefer to use Notepad++, which I have handy on my ToolBox USB stick. This editor is great for any type of language scripting, including Bash, Perl and Virtual Basic Script.
You'll also want the software development kit (SDK) and APIs provided by vendors to add their cmdlets to your environment. The ones I use the most are VMware's PowerCLI, Quest Software's Active Directory Management and Citrix's XenApp and XenServer SDKs. Many other enterprise app vendors have created cmdlets or support PowerShell calls via their APIs, and you should check to see if any apply to you and your daily administration and management tasks.
The code itself should take up the most space in your toolbox. Creating and maintaining collections of code snippets and functions is quick and easy, but organizing them so that you can easily refer to them and know what they do is another story. Don't get sidetracked by collecting as much code as possible. Instead, take the time to collect useful code and put it in your own repository, creating an index of sorts with comments and descriptions of the code and functions. While it may not be the best way to do it, I keep an index of my created and collected code in an OneNote Notebook on my laptop.
In addition, there are several repositories on the Internet that can help you find what you need at the click of a mouse. The two largest and best are Microsoft's Script Library and the POSHCode Repository.
One final note: IT admins should keep the items in their toolbox dynamic. Software is changing at light speed, with updates and patches making more headlines than the new releases. It's pretty much a fact that in our daily work lives, we need 26 hours in a day to get everything done that we need to get done (notice that I didn't say "want" to get done). For me, PowerShell has knocked off those extra hours of work time.
ABOUT THE AUTHOR
Mike Nelson has been in IT for over 20 years, with exposure to a very diverse field of technologies and solutions. He has devoted over half a decade to virtualization and server-based computing. Nelson is currently a senior analyst at a Fortune 100 company in the U.S. Midwest.