Windows PowerShell Runspace 10 Sample
This sample shows how to add a cmdlet to an InitialSessionState object and then use the modified InitialSessionState object when creating a Runspace object.
Sample Objectives
This sample describes the following:
- Creating an InitialSessionState object.
- Adding a cmdlet to the InitialSessionState object.
- Creating a runspace that uses the InitialSessionState object.
- Creating a PowerShell object that uses the Runspace object.
- Running the pipeline of the PowerShell object synchronously.
- Working with PSObject objects to extract properties from the objects returned by the pipeline.
Related topics
Operating system requirements
Client
Windows 8.1
Server
Windows Server 2012 R2
Build the sample
-
Start Microsoft Visual Studio and select File > Open > Project/Solution.
-
Go to the directory named for the sample, and double-click the Visual Studio Solution (.sln) file.
-
Press F7 or use Build > Build Solution to build the sample.
The library will be built in the default \bin or \bin\Debug directory.
Run the sample
- Start a Command Prompt.
- Navigate to the folder containing the sample executable.
- Run the executable.