Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


February 2005

Hottest Features of Monad

Windows shell scripting jockeys will love MSH and Monad
RSS
Subscribe to Windows IT Pro | See More Scripting Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

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.

End of Article



Reader Comments
Why use a proprietary shell when you can use
bash under Cygwin or superior scripting languages
like Perl or Python ?

Anonymous User August 02, 2005 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
10 Reasons to Deploy Windows Vista

The decision to upgrade your XP systems to Vista is simple when you consider features such as easier backup, a great desktop search, and vastly improved security options. ...

10 Reasons Not to Deploy Windows Vista

The decision to upgrade to Vista has to make business sense, but many companies find the costs in training and application compatibility problems outweigh any benefits Vista brings. ...

WinInfo Short Takes: CES 2009 Special Edition

An often irreverent look at some of the week's other CES 2009 news, including covering the Vegas spectacle from the comfort of my own home, Windows 7 public beta, a weird Microsoft song application, Palm Pre, pending Microsoft mobile moves, and much more ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing