Prev | Current Page 671 | Next

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

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

Commands.Add(MBXCommand);
CommandParameter verbParam = new CommandParameter(???Server???,
???MB001???);
EMSCmd.Parameters.Add(verbParam);
Command FTCommand = new Command(???Format-Table???);
pipeLine.Commands.Add(FTCommand);
Collection < PSObject > cmdResult = pipeLine.Invoke();
When adding commands to a pipeline this way, take care to ensure that the command is being passed
correctly typed data. Most of the cmdlets accept standard Int64, string, or byte quantified size for their
parameter values. However, a number of Exchange cmdlets have the filterscript parameter and
this parameter requires a value typed as a ScriptBlock and will not accept a string value. Creating a
ScriptBlock value isn ??™ t as straightforward as you might think. To create a script block you must create
a new RunspaceInvoke object and then cast the script as a ScriptBlock type. The code looks something
like this:
RunspaceInvoke rsi = new RunspaceInvoke();
ScriptBlock sBlock =
(ScriptBlock)rsi.Invoke(???{$_.DisplayName -match
\???Br\???}???)[0].BaseObject;
To create a ScriptBlock you cannot use a RunspaceFactory object like you are using to pipeline your
commands. You must use an instance of RunspaceInvoke to create a ScriptBlock. The RunspaceInvoke
.Invoke method returns a PSObject collection of the filterscript string you passed it.


Pages:
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
traktorki ogrodowe terapia magnetyczna Pompy zatapialne mapa Niemiec Wnętrza Poznań