Saturday, February 23, 2008

Hello Windows PowerShell

I have been frustrated for some time with DOS scripting. Fortunately, a colleague pointed me to Microsoft PowerShell (formerly known as Project Monad) for Windows XP and Windows Vista. PowerShell can be downloaded here and there are several scripts for use with PowerShell provided here. You can also download the Windows PowerShell Owner's Manual.

One of the things that is nice about PowerShell is that is supports many of the commands that we like to use in Unix/Linux. There are far too many useful things to demonstrate about PowerShell in one place, but the next two screenshots (click on them to see larger versions) demonstrate some Unix-like commands supported in Windows PowerShell.

The first screen snapshot demonstrates the very handy history command along with the ability to run a man (equivalent to help) command for a particular command.

The next screen snapshot shows the ls command along with the mv command. Having Unix equivalents makes it less frustrating to switch between Unix/Linux and Windows. Also, the ls and mkdir commands demonstrate the displaying of file modes.

Besides the Unix/Linux commands shown in the screen snapshots above, other goodies that are now available in PowerShell include pwd, ps, and cat. It is amazing how nice it is to have these little "extras" in the DOS scripting world.

Windows PowerShell requires .NET framework 2.0, so you'll need to get this if you don't already have it. There is much, much more to Windows PowerShell than what I've shown here so far. I think it is likely that I'll post future blog entries on other great features of PowerShell. It is even more likely that I'll start using PowerShell more frequently in my blog entries that show me running scripts, Java commands, the Flex compiler, etc. from the command line rather than using the old-style DOS terminal.

In related resources, Vaibhav discusses running PowerShell from Java. An interesting related article is A Return to Command-Line Control with Windows PowerShell. A free Windows PowerShell eBook is available as well. Finally, two other introductory references for using PowerShell are What is Windows PowerShell? and Top Ten Tips for Using Windows PowerShell Finally, a gentle introduction to Windows PowerShell is available in Discover PowerShell.

1 comment:

jsnover said...

Please make sure to blog what things you think we can/should do better. We are working on the next version and would appreciate any input on how to make it better.

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at: