One of the most exciting changes on the Windows horizon is the new scripting environment Microsoft is working on, which promises to revolutionize Windows scripting. The new environment has two parts: a new command-line shell, code-named Microsoft Scripting Host (MSH), and a new scripting language, code-named Monad. The command shell looks like a Windows command prompt, but the similarities between the old and new command shells stop there—the new Windows scripting environment is completely modern. Microsoft plans to include Monad in Longhorn, but it might also be made available for current versions of Windows. Check out the 10 hottest features in the new scripting language.

10. Task-oriented command names—Although most IT pros are familiar with Windows shell scripting commands, they'd be hard pressed to come up with a logical pattern behind the naming scheme. Monad replaces this nonintuitive command naming scheme with a new verb-noun approach. For instance, the following command retrieves the system drives:

MSH>get-drive

9. Arithmetic expressions—Unlike Windows shell scripting, Monad provides complete support for arithmetic operations. In addition to the standard operators, Monad supports a C-style shorthand of += for incremental operators, as in the expression

MSH>$result = 2 + 2

8. Conditional comparisons—Monad supports a variety of conditional indicators, including less than, less than or equal to, greater than, greater than or equal to, equal, not equal, like, and not like (-lt, -le, -gt, -ge, -eq, ne, -like, -notlike). The following command writes the word Equal to standard output when the result of 2+2 equals 4:

MSH>If ((2+2) -eq 4) \{write-host Equal\}

7. Looping constructs—Scripters will welcome alternatives to the useful but enigmatic For command. Monad's looping constructs also include While and Foreach loops. The following code uses a While command to write the result of a simple calculation five times:

MSH>while($int -lt 5) \{write-host $int; $int += 1)

6. Functions—Monad's support for function creation lets you create building blocks that encapsulate code routines. The following function returns the result of 2+2:

Function myTwos \{ $result = 2 + 2 \}

5. Variable scoping—Monad's scoped variables enable more robust code. You define the scope when you create the variable:

MSH>$local:mylocalint = 1

4. Dynamic command execution—Monad lets you dynamically build and execute commands. You can create the contents of a command dynamically in a variable, then execute that variable, as in the following example:

MSH>$cmd = get-commands
MSH>$cmd

3. Redirection—Monad provides full support for file redirection that works just as Windows shell scripting jockeys would expect. To list the system services in a file, you'd enter

MSH>get-service >> outfile.txt

2. Object piping—Instead of letting you pipe only text between commands, the MSH environment lets you pipe structured objects between commands, thus vastly ehancing code capabilities. The following example pipes the result of the Get-process command to the Sort command:

MSH>get-process | sort CP

1. Cmdlets—The coolest thing about Monad is that it lets you develop your own cmdlets, managed code objects that you create using one of the Microsoft .NET languages. Cmdlets let you seamlessly extend Monad's built-in functionality. You reference Monad's extensive set of built-in cmdlets using the verb-noun convention. For instance, you can use the cmdlet

MSH>get-command

to list all available cmdlets.