Every systems administrator and power user is very familiar with CMD.EXE: the command line interpreter for Windows. Its used for running applications from the command line, and also for performing administrative tasks with batch files. Not much has changed with the traditional command line interpreter from the days of DOS 1.0. The batch language has improved and more functionality has been added, but its still very limited and not as capable as Linux command shells (i.e. bash).
Taking on Bash
All of this has changed with Microsoft’s PowerShell. This is a vastly improved command line shell with a built-in programming language. The language is very similar in capabilities to PHP or Perl and works very well with creating small utilities for Windows. The big advantage of PowerShell over Linux shells is the vast .NET Framework that it has access to. You can write a script that can extract data from a Microsoft SQL Server database, send it by FTP to a remote folder, and then send an e-mail notifying a user where they can find the files that were transferred. Before this, a batch file would have to call external applications to perform the FTP and e-mail functions.
PowerShell scripting can easily be replaced by any of the Visual Studio .NET languages, but it has the advantage of being able to edit source code and immediately execute it.
Apart from scripting, the shell is also very good for executing commands, or cmdlets as they are called, from the command line. With this, you can perform complex operations that would require a great deal of programming to do.
Choose the Right Version
If you search Microsoft.com, you will find Windows PowerShell 1.0, but I would not recommend using this version. A better choice is the Community Technology Preview version of PowerShell 2.0. This version supports running scripts on a remote machine, creating cmdlets with its scripting language, reusable modules for organizing scripts, a GUI integrated scripting environment, and many more useful features.
Uninstalling PowerShell 1.0
Before you can install PowerShell 2.0, you need to uninstall version 1.0 if you installed it previously. This can be done by checking on the Show updates box in Add or Remove Programs (Control Panel). This is required otherwise Windows PowerShell will not be visible for uninstalling. You can find it in the Windows Software updates section.
Is It Worth Learning?
PowerShell is a powerful scripting language and can hold its own again PHP and Perl. The command line interpreter will save you time as a Windows administrator and you won’t go back to CMD.EXE or batch files after learning it. PowerShell is worth the effort in mastering it.
While PowerShell v2.0 has a wealth of new features it is NOT supported in a production environment. Technically it is not even an alpha product yet and things can change. You won’t waste any time learning PowerShell v1.0 as basic concepts and core cmdlets don’t really change. PowerShell v2.0 simply adds a lot of new stuff to the mix.
Jeffery Hicks
Microsoft PowerShell MVP
http://blog.sapien.com
follow me: http://www.twitter.com/JeffHicks
“Those who forget to script are doomed to repeat their work.”
Now Available: Managing Active Directory With Windows PowerShell: TFM
I downloaded and installed Microsoft’s PowerShell. I found it quit intreasting and useful. It gives a UNIX flavour.
PowerShell would make Windows more appealing to UNIX systems administrators.
Jeffery, I learned PowerShell with v1.0 but I decided to use 2.0 for the extra functionality it provided. While its not meant for use in a production environment, I’m using it in one with caution.
I hope that Microsoft will create a version of PowerShell that runs in Windows 2000 since I’m administering one server which could use the better scripting.
I needed to make sure your readers didn’t get the impression that Microsoft was offering them a version choice, because they really aren’t. Personally, I wouldn’t take the risk of run pre-pre release software in a production environment.
And unfortunately, I doubt you will ever see a version of PowerShell supported on Windows 2000, at least not from Microsoft. The features they are adding just can’t be retrofitted to Windows 2000. They have plenty of work just getting PowerShell v2 features to run on Windows XP and Windows 2003.
PowerShell would be great to replace all of the batch files I’m using on the Windows 2000 site, but I could also write simple apps in C# to do the same thing.
A great addition to PowerShell would be to have a choice to use any .NET language for scripting. I found examples in C# using Add-Type, but couldn’t get them to work.