Jump to content

PowerShell

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by IMSoP (talk | contribs) at 01:29, 21 June 2004 (written from scratch). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

MSH (short for Microsoft Shell; also referred to by the codename Monad) is a command line interface and scripting language being developed by Microsoft as part of their next operating system, codenamed Windows Longhorn. It is similar in usage to the more advanced Unix shells, but like most of Longhorn is based on object-oriented programming and the .NET framework.

History

Microsoft's first operating system was the text-based MS-DOS, which included a simlpe interface called command.com. Although certain features of this - and its successor under Windows NT, cmd.exe - were based on those of Unix shells, the latter are far more powerful. Indeed, as Windows was developed, more effort was put into providing graphical access to DOS features than vice versa, making many features of the OS awkward to interact with at the text-based level. This in turn led to some tasks being difficult to automate, as there was no scripting language immediately available to the user.

This contrasted with the traditional Unix approach, based on the philosophy of pipes and filters, where many tools were designed to have inputs and outputs as text, which could be fed from one to another via pipes. MSH aims to not only catch up with this approach, but take it one step further by taking advantage of the development of object-oriented design.

Central concepts

The system's codename comes from Gottfried Leibniz's "Monadology", a philosophy which says that everything is a composition of fundamental elements called 'Monads', which are all integrated together in 'pre-established harmony'. Similarly, the focus of MSH is on composition of complex tasks from a series of components. In this case, the components are special programs called commandlets (or cmdlets), which are .NET classes designed to use the features of the environment. The key difference between the Unix approach and the MSH one is that rather than creating a "pipeline" based on textual input and output, MSH passes data between the various commandlets as arbitrary objects.

If accessed individually from the command-line, a commandlet's output will automatically be converted into text, but if its output is to be used by another commandlet, it will be converted into whatever form of object is most appropriate for that commandlet's input. This has the advantage of eliminating the need for the many text-processing utilities which are common in Unix pipelines, such as grep and awk, as well as allowing things to be combined interactively, or in a scripting environment, which would otherwise require a more complex programming language. For instance, a listing of processes will consist not of text describing them, but objects representing them, so that methods can be called on those objects without explicit reference to any outside structure or library.

MSH is part of an overall strategy within Longhorn to treat all parts of the OS as .NET objects, and thus allow the user greater flexibility over how they are used. This is aimed to make previously complex interactions manageable within the bounds of frameworks such as MSH; for example,Longhorn's registry can be exported as though it were a filesystem, and navigated by treating it as a hierarchy of files and directories.

Features

Although still in development, a number of key features of MSH have already been revealed, including:

  • commandlets all inherit certain options, allowing the user to choose things such as the level of interaction and how to deal with errors - including a "suspend" feature, which allows the user to enter a new command shell, investigate a problem, and then continue with the original command. A simple mechanism is built-in for the programmer to define the prompts to be shown in such circumstances.
  • options are generally whole words, but can be specified to the minimum number of letters necessarily (e.g. the option -show-detailed-information could be entered as -s if no other option began with 's')
  • tab completion
  • the ability to assign the output of a command to a variable, which will then be an object or array of objects inspectable in any way desired