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 -?


Retrieves the child items <snipped>

Gets the child item(s) <snipped>
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]

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

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::
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

Comments (9)

  1. MSDN Archive says:

    In case others run across this – TFVC already has a provider – I even put up the source on GDN


  2. FenianEMT says:

    I played with Monad a while back.  It’s definitely pretty cool.  Now if MS would provide it with a console that wasn’t absolute crap, I’d be really happy.  PowerShell would be really cool with a rich console (imagine Intellisense for your commands), but Microsoft seems determined to stick to that stone-age copy of an MS-DOS monitor in a window.

  3. Why do you say the console is crap?? Agreed it does not support intellisense, but have you used auto-complete (tab), previous command recall (F8), history (F7)? I think it is a decent console windo.

    But then again there is plenty of scope to improve. I guess Powershell is the beginning. Now the console can think about intelli-sense and other reflection oriented features…

  4. Manip says:

    I have to side with FenaianEMT on this one. The console needs standard hotkeys (CTRL-P, C, etc); it needs to have auto-complete (Tab is not really an alternative because you have to hit it constantly to know if it will work).

  5. FenianEMT says:

    I guess the best response I can give you is to try playing with some of the Xterm applications and then come back and try the microsoft console window.  But some simple questions: Why can’t I drag to resize the console window?  Is it really that hard to have it dynamically change the console dimensions as you drag?  And it’s just silly that it can’t store the entire buffer of a console session.  The font options are pretty weak.  I could go on.  I think intellisense would be a really good idea, but that was more of a suggestion for a totally new feature.  I don’t know of any such application that supports something like that.  But there’s no reason not to and many reasons it would be a good idea.

  6. Fenian I agree that the console is not as advanced as it should be and the age is clearly showing. But have you tried PowerShell. Its way-way ahead of Unix shells.

  7. FenianEMT says:

    Like I said, I played with Monad a while back.  I’ll have to download PowerShell and mess with it a bit.  Monad did seem like it’d be really cool if I could spend the time to properly learn the ins and outs of it.

  8. In PowerShell I ran (dir *.exe).Count to see the number of executables in System32 folder in a Vista…