The new Windows command shell
At the Professional Developers Conference (PDC) 2003, Microsoft announced a new scripting solution code-named Monad. Monad will provide a new hybrid command shell and scripting language known currently as Microsoft Shell (MSH). As with most code-named solutions, MSH will probably be replaced by another name when the shell and language are released. Although Microsoft isn't anywhere near shipping MSH, the new tool looks like it should have a significant impact on administrators in the next few years.
Even at first glance, the early MSH beta is strikingly superior to cmd.exe as a tool. MSH is a stream-oriented shell that draws its syntax and concepts from sources as diverse as Korn shell (ksh), the VMS Digital Command Language (DCL), and even SQL (for queries). Its provider framework extends the standard navigation commands for a file system to complex structures such as Windows Management Instrumentation (WMI), Microsoft Active Directory Service Interfaces (ADSI), and the registry. Currently, MSH runs in a console shell, but don't let that mislead you into thinking that MSH is just another text-processing shell. MSH uses a console right now because complete support for Telnet access is a design goal; what you see on screen is a representation of full-featured Windows .NET Framework objects passed through a pipeline.
MSH has quite a bit more infrastructure than is immediately apparent. Historically, Windows developers have neglected building flexible, scalable administrative tools because Windows has a minimal support framework (e.g., Windows has no standard tools for parsing command-line options). Thus, writing such tools takes a tremendous coding effort. MSH provides a base class for task-focused tools called cmdlets (pronounced commandlets), which automate command-line parameter parsing and Help summaries. This base class lets developers write a cmdlet in as little as one line of custom code and ensures a consistent syntax for all cmdlets.
To give you a feel for MSH, Listing 1 shows some one-line code snippets that perform common tasks. (Keep in mind that the syntax and aliases might change before MSH's release.) Even though MSH is in early beta and has to deal with cumbersome COM and Microsoft .NET namespaces, you can get useful information and perform real tasks from the MSH prompt.
As of this writing, Microsoft hasn't announced which Windows versions will support MSH or when it will be released, but its developers say that it's a Longhorn-era product dependent on the next .NET runtime release. The current beta runs on Longhorn, Windows Server 2003, and Windows XP. Fortunately, you can use MSH on a supporting system from any system that runs a Telnet client—so, yes, you can use MSH to administer a LAN from your favorite handheld device.
I use many scripts that run in the command shell and Windows Script Host (WSH), so I was concerned about MSH's interoperability with these tools. Some standard strategies work very well right now. Console scripts can share text data with MSH through standard input, output, and error streams. MSH will not only read and write text instead of objects but also provide text-manipulation tools that I already prefer to their command-shell predecessors. Finally, MSH lets you reference and manipulate COM classes even more easily than WSH does. This direct access applies to .NET classes as well.
For more information about MSH, you can download the Windows Hardware Engineering Conference (WinHEC) 2004 Microsoft PowerPoint presentation about MSH at http://download.microsoft.com/download/1/8/f/18f8cee2-0b64-41f2-893d-a6f2295b40c8/tw04038_winhec2004.ppt or see the recent .NET Show video about it at http://msdn.microsoft.com/theshow/episode043/default.asp. If you want a closer look at the future of the Windows command line, I strongly encourage you to join the MSH beta program. Just remember that MSH is an unsupported beta product and shouldn't be used on production systems. To join the beta program, go to http://beta.microsoft.com and sign in with a .NET Passport account. (If you don't have one, the sign-in page has a link for creating one.) Once inside the beta site, when asked for a Guest ID, type in mshPDC. You should receive beta information within 48 hours and will be able to download the .NET version required by MSH and the MSH beta. You can also participate in the beta newsgroups for MSH and provide feedback to the MSH developers.