Saturday, September 2, 2006

Windows PowerShell

I recently discovered the Windows PowerShell. This new shell has some really nice concepts. Unfortunately right now the documentation is rather spare and you have to search a lot before being able to:

sort the process list by reversed process names:
ps | sort-object @{ Expression = { $chars = $; [system.array]::reverse($chars); new-object String(,$chars); } }

Unfortunately the reverse method is in-place, so it took me some time to get this rather easy example working, but it shows that the .Net library is readily accessible within msh.
Especially the piping of real .Net objects is a wonderful innovation in shell context. In the Unix world the most daunting part of shell scripting is often to find the correct language independent regular expression to extract data from the input process. msh introduces yet another programming language to the scripting universe, but at a first glance the designers did a very fine job - the orthogonal concepts are ready for the textbook.

No comments:

Post a Comment