Prev | Current Page 670 | Next

Joezer Cookey-Gam, Brendan Keane, Jeffrey Rosen, and Jonathan Runyon

"Professional Windows PowerShell for Exchange Server 2007 Service Pack 1"

After that the FTCommand object is created for
the Format-Table command before it is added to the pipeline:
Runspace EMSRunSpace = RunspaceFactory.CreateRunspace();
EMSRunSpace.Open();
Pipeline pipeLine = EMSRunSpace.CreatePipeline();
Command MBXCommand = new Command(???Get-Mailbox???);
pipeLine.Commands.Add(MBXCommand);
Command FTCommand = new Command(???Format-Table???);
pipeLine.Commands.Add(FTCommand);
Collection < PSObject > cmdResult = pipeLine.Invoke();
This example takes the results of the Get-Mailbox command and pipelines it to the Format-Table command.
But what if you wanted to select only mailboxes that are hosted on the MB001 server? You need to
Part IV: Automating Administration
490
add a parameter to the Get-Mailbox command. For instance, if you need to run Get-Mailbox -Server
MB001 , you need to use the pipeline.command.add method to add in Get-Mailbox as the command
that needs to run and then use the command.Parameters.Add method to add Server and MB001 to
modify that command. The CommandParameter class requires only a name in the case of a switch parameter
and a name and a value for parameters that have additional values:
Runspace EMSRunSpace = RunspaceFactory.CreateRunspace();
EMSRunSpace.Open();
Pipeline pipeLine = EMSRunSpace.CreatePipeline();
Command MBXCommand = new Command(???Get-Mailbox???);
pipeLine.


Pages:
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
Survivor Bruce Springsteen Eddie Thoneick Tede Tiamat