Saturday, May 06, 2006

Windows PowerShell (aka Monad)

Microsoft published Windows PowerShell RC1 - a new task-based command line shell and scripting language for system administration. - The according Team Blog for PowerShell here.

From the marketing perspective, you get...
  • As interactive and composable as BASH/KSH
  • As programmatic as Perl/Ruby
  • As production oriented as AS400 CL/VMS DCL
  • Access data stores as easily as accessing filesystems

Now, examples and code! I'm interested from a developer-perspective. Especially, if i'm able to replace some VB-Scripts with PowerShell Scripts. - It seems to be possible - with less code.

The first command to start with: get-help * (Wow, what a huge list)

I'm interested specially in the power of language constructs.

As a sample, a foreach implementation to loop thru file in the current directory and display a message for files with a size over 100k:

$i = 0
foreach ($file in Get-ChildItem)
if ($file.length -gt 100k)
Write-Host $file "file size:" ($file.length / 1024).ToString("F0") KB
$i = $i + 1

Cool! Easy to read! - But is it also easy to write, without digging thru the whole documentation... at least not for me. So, what about an IDE with intellisense (code completion), dynamic help etc. to get productive fast? - I googled thru the web, and found this blog-entry. According to this, Primal Script, a really powerfull Script-IDE (I use it for VB-Scripts) will give us this support soon.

I'm sure, with an IDE and the Power of PowerShell, this will be a new area in Command-Lining, Batching on Windows - Back to the roots, but with new Luxury! :-)