Guy's Scripting Ezine 108 - Mission Monad (PowerShell)This week I have a simple mission, to persuade you to download a free copy
of Microsoft's Monad. Note that in May 2006 Microsoft revealed that the code name Monad would now become PowerShell, indeed they have now released a later version RC 1. My killer reason for introducing you to the Monad scripting shell is that you will need a passing knowledge of this new language to configure Exchange 12 (E12). (E12 will be the replacement for Exchange 2003). Putting aside Exchange, Monad will one day become the standard Microsoft command line shell this is why I exhort you to at least have a look. I say
again Monad is free, so all you need is a spare half hour to try out the powerful new commands in the MSH shell. Unlike virtually any other program that I know, Monad is truly easy to get started. If you
know DOS or cmd.exe, then you can simply type commands such as cd, dir or even ipconfig. Those familiar with COM, WMI, ADSI .NET XML or even UNIX experience the same phenomenon, many of their old commands work
in Monad.
If you are looking for handy network utilities, try some of the free downloads at
Tools4Ever
Guy's Initial Reaction to MonadAs you may know, I have no scripting pedigree, I am just a minor expert at configuring VBScript on Windows systems. Here are my initial reactions. Monad really is
straightforward to get
started. Principle 1: The heart of Monad is always a verb-noun pair, linked with a hyphen. For example, set-location is the equivalent to cd in DOS. Incidentally, the reason cd works in Monad is because
it has a built in Alias called cd which maps to
set-location. Moreover, good news, you can create your own aliases. Examples of Monad I know these are non-exchange
examples but I want to get you
up and running: Preamble, Start, Run MSH. In the black shell type: get-process or get-Win32_NetworkAdapter Principle 2: Create cmdlets. Save your text commands in a
text file with an .msh extension. Then execute these cmdlets from
within the Monad shell.
The only trick in executing the cmdlet is to type plain: dot slash filename. Example: .\guy do not to add the .msh extension. This is wrong .\guy.msh.
# # This cmdlet generates a report about memory in active processes #
"Report generated at " + (get-date) "" # insert blank line
"High memory usage (>100000000)"
get-process | where-object { $_.VirtualMemorySize -gt 100000000 }
I will give more detailed instructions in future ezines or on the website, the above is merely an example of a cmdlet to give you the method. Remember my mission this week is to
persuade you to download and install the free copy
of Microsoft's PowerShell RC1.
How did I get started?I read the help files! There were about 6 files which came with the Monad download, I
printed and read the 85 page 'Getting Started' document. Next I copied and pasted the examples into cmdlets, figured out how to execute them by manoeuvring to the script directory and typing dot slash
filename (no extension). For example: .\procmem As soon as I installed the .Net Framework and the Monad executable, I was able to start and stop services. Then I issued commands to interrogate the
Event Logs for a specific ID, I was also able to get a filtered list of processes. All I did was type the 'get' verb linked by a hyphen to the appropriate noun: service, processor or eventlog application,
for example, get-service. With eventlog it was best to filter e.g. get-eventlog application | where {$_.eventid -eq 1704} There has to be more to Monad than this?Yes, there is
masses more that Monad can do! So far I have only scraped the surface and
only mentioned the simplest of instructions. Earlier I gave a few hints that Monad has the power to rival C#, COM, perl. Another hint that Monad will be powerful is that you have to install .Net Framework
before you install Monad. If I could revert to Exchange 12 for a minute. While Exchange 12 will have a GUI for all the basic tasks, for repetitive tasks or clever configurations, Microsoft is saying that you need to
learn Monad. For example, at the E12 Ignite show I saw a smart Monad script, which not only created users and their mailboxes, but also load balanced their mailboxes between storage groups. My
ultimate mission is that you will be able to copy, understand and then modify such Monad cmdlets. Here is the reason that I started
with the basics.After I got Monad installed and mastered a few simple commands, I listened to two 90 minute Microsoft Webcasts of Monad. If I had listened to the presentation first, I would
not have gone any further, I would have thought, 'Monad is too difficult for non-programmers like you Guy'. However, there was a very important hidden message, the presentation was saying to me, 'This is a seriously powerful
scripting language'. The speaker explained how Monad could do stuff that people now do in UNIX, perl, C++ or Visual Basic. One day I will return that presentation there is so much for me to
learn about scripting principles in general and objects in particular. Summary of Monad MissionWell, have I sold you a free Monad download? If I see that enough people give Monad a try,
then after Easter I will devote a handful of ezines to Monad, if not I will revert to VBScript. Either way, I will be creating a new Monad section on my website.
Free copy
of Microsoft's PowerShell
PowerShell Introduction
Their topics and material are ideal for getting you started with VBScript. The
videos are easy to follow and you can control the pace. Try their free demo material and then see if you want to buy the full package.
See more about VB Script Training CD.
|