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
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

The Memory-Optimization Hoax

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

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


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

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.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

IT Connections
Dive into the new Microsoft platforms and products you implement and support with the experts from Microsoft, TechNet Magazine, Windows ITPro and industry gurus. There are 70+ sessions and interactive panels with networking opportunities.

Attention User Group Leaders...
Announcing the eNews Generator—a FREE HTML e-newsletter builder for user group leaders. Build your HTML and text e-newsletters in minutes and add Windows IT Pro & SQL Server Mag articles alongside your own message!.

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Get SQL Server 2008 at WinConnections
Don’t miss Microsoft Exchange and Windows Connections conferences, the premier events for Microsoft IT Professionals in Las Vegas, November 10-13. Every attendee will receive a copy of SQL Server 2008 Standard Edition with one CAL.



Interested in Email Encryption?
Read about the advantages of identity-based encryption in this free report.

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16.
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 Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 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