2008-10-14

PowerShell

A few weeks ago I had a chance to attend a workshop about PowerShell entitled "Using PowerShell" by Ed Wilson. Fantastic teacher and fantastic person to talk to about anything.

This was my first time using PowerShell. I had tried one of Monad's first versions but it took so much time to load and crashed so many times I decided to wait for a final version. I ended waiting a bit more than the final version though. My first impression was "This is fantastic!!". And it really is.

Being a lover of the command line and an avid user of Bash and other UNIX shells, I welcome PowerShell. I'm not going to compare Bash and PowerShell and try to guess the best shell. In my humble opinion, they're not comparable. For that kind of entertainment, google for PowerShell vs Bash. You'll probably get a lot of results with links to endless and pointless discussions between UNIX and Windows zealots.

PowerShell and Bash have very few similarities. Quoting Ed Wilson "PowerShell was done by UNIX guys. Pony tail and all" so it's not so much a surprise to see aliases to PowerShell commands (called cmdlets) that look like Bash commands but they actually do different things even though the visible result might look similar. But that's it.

For instance, ls in Bash gives you a list of files in the current directory. In PowerShell, ls is an alias to Get-ChildItem. This cmdlet "Gets the items and child items in one or more specified locations." (type man get-chilitem or man ls in PowerShell for this :) ). If the location is a directory, you get a list of objects of the type FileInfo. Each of this objects have properties (ex: Name, LastWriteTime) and methods (ex: Open, MoveTo). This info, by default, is displayed as a basic listing of files but it's much more than that.

PowerShell and Bash are fundamentally different and are built for different platforms using different resources. In PowerShell everything is an object. PowerShell brings the power of Microsoft .Net Framework at you finger tips, makes using WMI easier and is built for Windows systems, integrated and one. Bash lives of individual third party tools and binds them together.

I plan to post some of my first experiments with PowerShell as examples.