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
VMware and the Future of Virtualization

What's next for virtualization and business IT? Windows IT Pro senior editor Jeff James speaks with VMware President and CEO Diane Greene on the future of virtualization technology. ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

What service packs and fixes are available?

...


Windows OSs Whitepapers Replay for Exchange: Enterprise Protection and an Affordable Price

Are You Satisfied?

A Preliminary Look at Deployment Plans for Microsoft Windows Vista

Related Events 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.


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Critical Challenges of ESI & Email Retention
Are you storing too much electronic information? Get expert legal advice and better understanding of what you are required to do as an IT professional.

Become a fan of Windows IT Pro on Facebook!
Join us on Facebook and be a fan of Windows IT Pro!

Sustainable Compliance: Are You Having a Resource Crisis?
Read this white paper to examine trends in compliance and security management and review approaches to reducing the cost and operational burden of compliance.

Rev Up Your IT Know-How with Our Recharged Magazine!
The improved Windows IT Pro provides trusted IT content with an enhanced new look and functionality! Get comprehensive coverage of industry topics, expert advice, and real-world solutions—PLUS access to over 10,000 articles online. Order today!

Get It All with Windows IT Pro VIP
Stock your IT toolbox with every solution ever printed in Windows IT Pro and SQL Server Magazine plus bonus Web-exclusive content on hot topics. Subscribe to receive the VIP CD and a subscription to your choice of Windows IT Pro or SQL Server Magazine!



Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.
Windows IT Pro Home Register About Us Affiliates / Licensing Media Kit Contact Us/Customer Service  
SQL Connected Home IT Library SuperSite FAQ Wininfo News
Europe Edition Office & SharePoint Pro Windows Dev Pro Windows Excavator 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing