On MSH - The Longhorn Command Shell
The Longhorn command shell - MSH (Microsoft Shell)- was announced at the 2003 PDC.
This is a Longhorn technology currently in beta. Although the current beta is written against Whidbey assemblies, its likely (?) that the initial public release of MSH will only be as part of the commercial release of Longhorn.
MSH is a managed host application and class library that provides a new command based scripting environment and language. That language can be extended through the creation of new commands (Cmdlets), which are simply assemblies containing one or more classes decorated with a custom System.Attribute.Those assemblies placed in the MSH folder are auto-discovered through reflection on starting MSH.
Additionally, a number of Cmdlet Provider classes are provided which can be sub-classed in order to support the custom navigation or browsing of resources (e.g. file system, AD, registry etc.) in a consistent way.
The host application is merely an implementation of an interface exposed through the class library, meaning that you can create your own, or incorporate host type functionality within your application.
But by far, the most significant feature (IMHO) of MSH is the implementation of a structured object based pipeline. Currently, command line programs can receive (via std I/O) the output of another program. That mechanism uses the pipe (|) mechanism as shown in the line below:-
c:> dir | sort /r
The input received by the sort program is text and is unstructured. One can of course parse the text but that is relatively difficult and unreliable. MSH offers an object based pipline which means that a command can output (and another command can receive) rich (CLS Type based) objects.
This means that one can string together small, yet powerful, building-block-like commands such as the following:-
MSH C:\> get/process | where/object "handlecount -gt 400" | format/list
or
MSH C:\> get/process | where/object -Expression "processname -like *cs*"
Note here that the where/object command acts on the handlecount and processname properties of the output of the get/process command.
I'll try to write more about the structured object pipeline and how it works internally another time.
MSH is part of Microsoft's Dynamic Systems Initiative (DSI). See here for Q&A on DSI and here for some information on the System Definition Model (SDM).