Windows PowerShell Runspace 5 Sample
This sample shows how to create an initial session state and then use the initial session state when creating the runspace. This sample assumes that user has the GetProcessSample01.dll that is produced by the GetProcessSample01 sample copied to the current directory.
Sample Objectives
This sample demonstrates the following:
- Creating a default initial session state.
- Creating a runspace using the default initial session state.
- Creating a PowerShell object that uses the runspace.
- Adding the
Get-Proccmdlet to the PowerShell object from a snap-in. - Using PSObject objects to extract and display properties from the objects returned by the cmdlet.
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.