Invoke();
foreach (PSObject cmdlet in cmdData)
{
string cmdletInfo =
cmdlet.Properties[???Name???].Value.ToString();
}
489
Chapter 17: Using the .NET Framework
To provide useful information you will most likely need to provide more than just a single cmdlet
without any parameters. To run a more complicated set of commands or even a full script, call the
CreatePipeline method with the entire command text. The code would look something similar to
the following:
Pipeline pipeLine = EMSRunSpace.CreatePipeline(???get-mailbox
| where-object ??“
filterscript {$_.DisplayName = \???Rivera\???}???);
At this point it may be beneficial to mention the CreateNestedPipeline method. This method works
much like CreatePipeline does in the previous example; however, it is used if you need to build
another pipeline when you already have one running in your runspace. This allows you more flexibility
in your application because you do not have to wait for the current pipeline to complete before creating
the new pipeline.
Calling the method with the entire command text is a quick way to run a simple set of commands. But,
what if you need to programatically build a conditional command list? Perhaps if certain conditions were
met you might need to add specific cmdlets to the pipeline. The CreatePipeline method can also create
a pipeline without first passing it a command or a list of commands.
Pages:
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680