Examples of Creating Runspaces

This section includes examples that show the different ways you can create an individual runspace in a host application.

In This Section

How to Create a Runspace
This example shows how to create an individual runspace that can be used to run the commands of a command pipeline. In this example, the host application does not specify any configuration information such as custom host or an initial session state.

How to Create a Default Initial Session State
This example shows how to create a default initial session state that includes the elements provided by Windows PowerShell, how to create a runspace that uses the default initial session state, and shows how to use the runspace.

How to Create a Default Initial Session State
This example shows how to add an initial session state to a runspace. In this example, the host application defines two variables and two functions that are loaded into the session when the runspace is opened. Once the runspace is opened, the application runs commands to show that the elements are available.

How to Create a Remote Runspace
This example shows how to create a runspace that uses WS-Management-based remoting to run commands on the local host. This same code could be used to connect to a remote computer.

See Also



Show:
© 2014 Microsoft