How does Select-String work with Pipelines of objects?

<Edited to convert Match-String to Select-String 7/9/2006> In our newsgroup (Microsoft.Public.Windows.Server.Scripting) , Vasu asked about how Select-string works in pipelines: Here is what I observe:1. MSH C:\> get-alias ..truncated..Alias           ri                                   remove-itemAlias           rni                                  rename-item..truncated..2. MSH C:\> get-alias | select-string ririMSH C:\> The question is why did the string “ri” get emitted instead of the alias record. So what… Read more

Check Spelling Script

After reading Marcel’s introductory piece on ScriptBlock, I decided to rewrite an old script of mine that checks the spelling of all text files in a directory. Here is what I came out with. #region Parse a line to a list of words $StringFind ={param ($str, $start, $cond)  if ($start -ge 0 -and $start -lt $str.Length) {    for($i = $start;… Read more

Base64 Encode/Decode a string

Today I came across  . This sight is focused on Monad and MSH and is starting a collection of scripts at: .  You should visit their site and let them know what type of scripts would be useful to you.  I particularly liked their entry on how to Base64 encode a file.  This is… Read more


Monad provides a way to create new com objects with new-object $ie = New-Object -ComObject InternetExplorer.Application$ie.Navigate2($ie.Visible=1 Great but what about if you want to bind to an existing object?  Where is the equivalent of GetObject()? This is one of those good new/bad news stories.  First the bad news.  Monad does not provide a Cmdlet that… Read more

Monitor the Event Log

Administrators often want to monitor the event logs and look for specific error conditions.  The most capable way to do this, of course, is to use a dedicated monitoring application such as Microsoft Operations Manager, or get down-and-dirty with the Win32 API NotifyChangeEventLog.  However, Monad can be used for simple applications. Suppose you are looking… Read more

Why did you do that? $VAR/ {} / Weak Intellisense

I strongly encourage people to let us know where we could be doing better and to let us know if we are getting into the weeds.  I believe that being open to such bad news is core to the the virtuous cycle of self improvement so such feedback provides opportunities to reflect and make changes when appropriate.  Other… Read more

A bit about Scriptblocks

When scripting with MSH one of the most useful things to know about are scriptblocks (lambda functions).  Scriptblocks are compiled bits of MSH script which you can pass around and invoke whenever you feel like it.  They turn out to be so useful that if you look at the cmdlets you’ll find a few that… Read more

Monad portal in Script Center.

Most scripters are familar with Microsoft script center.  Script center now has a portal for Microsoft Command Shell.  You can access the portal at -Arul Kumaravel [Edit: Monad has now been renamed to Windows PowerShell. This script or discussion may require slight adjustments before it applies directly to newer builds.]… Read more

PINVOKE or accessing WIN32 APIs

In the very early days of Monad, we focused on a world where everyone would publish Cmdlets and providers.  Cmdlets and providers were designed around providing the best user experience.  They provide the right, high-level, task-oriented abstractions that users want while also providing the semantic benefits that the Monad engine provides (-WHATIF, -CONFIRM, -VERBOSE, -ERRORACTION, -ERRORVARIABLE, etc etc). … Read more

Using-Culture -Culture culture -Script {scriptblock}

One of the traditional challenges with scripting is dealing with different CULTURES.  Imagine the case where you are writing a script and you’ll have to parse datetime string from different cultures.  If it was just one culture, you could set the process culture and be done with it.  Here is a function that allows you to… Read more