Exchange Exchange
A community dedicated to Exchange and related technology.

Vivek explains power shell pipelines

rated by 0 users
This post has 1 Reply | 0 Followers

Top 10 Contributor
Points 3,290
Joel Stidley Posted: 07-29-2006 1:07 AM

Check out his whole post here

We already know that Monad is as powerful (or more) than some programming languages. But is it required to do complex scripting in Monad to do simple things? Do you have to learn all the knob and switches in order to use it to manage Exchange? When we started designing the Exchange cmdline and scripting interface, we made absolutely sure that 80% of our customers, who normally have little or no scripting experience, can still use Monad/Exchange cmdline to auotmate or perform their tasks. Eileen has a similar question on her weblog as well. Let me give some examples (these are all public already so you’ll have to wait for new stuff later on, sorry!):

   get-mailbox -server LAServer |
            move-mailbox -targetdatabase OaklandSG\OaklandMDB

What is this line doing? It looks cryptic as the syntax is new and there’s the new operator “|” in the middle of the sentence. The “|” character should already be familar to the unix folks, and is possibly the first (and only?) concept that you have to learn to get some good mileage out of the Exchange cmdline. What it means is: take the results of the operation on the left hand side and pass those results to the operation on the right hand side. Like this:

Check out his whole post here

 

- Joel

  • | Post Points: 0
Top 10 Contributor
Points 3,290

The power shell team adds a little bit more to Vivek's explaination here

Flexible pipelining with ScriptBlock Parameters

PSMDTAG:FAQ: How can I pipeline data to a parameter which does not accept pipeline input?
PSMDTAG:FAQ: What are ScriptBlock Parameters?

One of the foundation concepts of Windows PowerShell is pipelining objects instead of text.  What happens is that when an upstream command generates an object, the PowerShell engine examines the data requirements of the next pipeline element and then binds the pipeline object to it.  That binding can either be:

  • Accepts Pipeline Input - BYVALUE
  • Accepts Pipeline Input - BYPROPERTYNAME

You can see this when you look at the Parameter section of the help for any cmdlet.  Take a look at the Help for Get-Process, you see the following:

Continue at source

- Joel

  • | Post Points: 0
Page 1 of 1 (2 items) | RSS
© 2003-2009 NamedPipes Consulting. All other company and product names are property of their owners.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems