Examples of Host Application Code
This section provides examples of how to write host applications, how to create runspaces and runspace pools, and more. All of the examples in this section use the PowerShell object to create the command pipeline and to run the commands of the pipeline.
In This Section
This section includes the following topics.
- How to Write a Simple Host Application
- This example shows how to write a host application that invokes a command synchronously on the local computer.
- How to Add Commands to the Pipeline
- This example shows how to add cmdlets and their parameters to the command pipeline of a host application. After the command pipeline is complete, the host application invokes the pipeline synchronously on the local computer.
- How to Add a Custom Host
- This example shows how to add a custom host to a host application. The following procedure highlights what is needed to specify a custom host implementation.
- Examples of Creating Runspaces
- This section include examples of the different ways the host application can call the CreateRunspace method.
- Examples of Creating Runspace Pools
- This section include examples of the different ways the host application can call the CreateRunspacePool method.
- Examples of Invoking Pipelines
- This section includes examples that show how to invoke a pipeline synchronously or asynchronously. In these examples, the Windows PowerShell object is used to define the pipeline and to invoke the pipeline.
- Examples of Custom Host Class Implementations
- This section includes examples that show the different ways you can implement a custom host classes, including their related interfaces for supporting prompts for multiple choices and supporting interactive sessions.
Other ResourcesWriting a Windows PowerShell Host Application