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

More fun TechEd 2005 Resources

Kevin points out some more TechEd resources ...

Outlook Tips and Techniques

Read about hiding items, merging appointments, multiple windows, creating views, permissions, sending Outlook items to outside recipients, Send As permission, Inbox Assistant, tricks for rules, and tips for obtaining Microsoft Knowledge Base articles. ...


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

Microsoft Exchange & Windows Connections event returns to Las Vegas Nov 10 - 13
Connections returns to Las Vegas for this exciting event where each attendee will receive SQL Server 2008 standard with 1 CAL. Co-located with Microsoft ASP.NET, SQL Server, and SharePoint Connections with over 250 in-depth sessions.

Free Online Event! Virtualization:Get the Facts!
Register now and attend this free, live in-depth online conference on November 13 and 20, 2008, produced by Windows IT Pro. All registrants are eligible to receive a complimentary one-year digital subscription to Windows IT Pro (a $49.95 value)!

Check Out Hyper-V Video on ITTV
Watch Karen Forster's interview on Hyper-V's performance on ITTV.net.

Ease Your Scripting Pains with the Flexibility of PowerShell!
Join MVP Paul Robichaux on December 11, 2008 at 11:00 AM EDT as he equips you with PowerShell basics in 3 introductory lessons, each followed by a live Q&A session—all on your own computer!

PASS Community Summit 2008 in Seattle on Nov 18-21
The don’t-miss event for Microsoft SQL Server Professionals. Register now and you’ll enjoy top-notch Microsoft and Community speakers and more.



Solving PST Management Problems
In this white paper, read about the top PST issues and how to administer local/network PST Files.

Get Protected -- Data Protection Manager 2007
Protect your virtualized environment with Data Protection Manager

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.
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 © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing