I just fell in love with PowerShell (aka Monad)

Unfortunately I had not experimented with Monad before. Yesterday our blog server got swamped with new posting on PowerShell blog, a little poking around revealed that Monad has been renamed to PowerShell. I couldn't believe my eyes, I had expected that it'd be remaned to Microsoft Windows Shell.NET 2007 Professional Edition :)

So feeling a bit guilty I installed it on a XP box and started poking around. So to see the help I tried the following

 PS C:\> dir -?

NAME
    Get-ChildItem

SYNOPSIS
    Retrieves the child items <snipped>

DETAILED DESCRIPTION
    Gets the child item(s) <snipped>
USAGE
    Get-ChildItem [[-Path] <System.String[] >] [-Incl <snipped>

I was surprised to see the help looked like Man pages!! Moreover the .NET backbone raised its head (intentionally) when parameter types are shown as System.String. I loved the fact that most common shell commands like dir, del have been aliased to corresponding PowerShell (MSH) commands.

The help was huge and I just wanted to see the usage and I tried the following

 PS C:\> (get-command Get-ChildItem) .definition
Get-ChildItem [[-Path] <String[]>] [[-Filter] <String>] 
[-Include <String[]>] [-Exclude <String[]>] [-Recurse] 
<snipped>

This proves the true power of a object-oriented shell. You can just use the fields/properties as in .definition!

I wanted to find large files in a folder which were not log files and I could do it as 

 PS C:\> get-item .\*  -exclude *.log  | sort Length -descending


    Directory: Microsoft.PowerShell.Core\FileSystem::C:\
Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---          3/7/2006   6:19 PM    1440024 img2-001.raw
-a---         3/17/2006   5:37 PM     423589 FuncTest.zip
-----        10/22/2004   7:47 PM     294512 NTLDR
-----         3/25/2003   6:00 AM     278688 CMLDR
-a---        10/26/2004   2:16 PM     145466 uiprestore.cmd
-a---         10/5/2005   4:16 PM     141415 rss2.html
<snipped>

The other thing I tried out just bowled me over and I instantly made PowerShell my default shell. I wanted to rename a registry key and I was able to do it as follows

 PS C:\> cd HKCU:
PS HKCU:\> cd 'HKCU:\Software\MyCompany\'
PS HKCU:\Software\MyCompany> ren MyProd MyCompany_org
PS HKCU:\Software\MyCompany> dir
   Hive: Microsoft.PowerShell.Core\Registry::
     HKEY_CURRENT_USER\Software\MyCompany
SKC  VC Name                           Property
---  -- ----                           --------
  1   0 MyCompany_org                  {}
  1   0 Licensing                      {}

So I was just able to use the registry seamlessly as the file-system, list keys using dir and delete using del!! Regedit RIP. I guess the next target of Team Foundation source control would be create a provider to integrate with this model.

I've just experienced the future of all shells and just wanted to share my excitement with fellow developers. This is one big success story for .NET