Windows PowerShell Host04 Sample
This sample application shows building a fairly complete interactive console-based host which allows users to run cmdlets and see the output.
This sample reads commands from the command line, executes them, and displays the results to the console. The sample user interface classes are built on top of System.Console.
Sample Objectives
This sample demonstrates the following:
-
Creating your own host interface, host user interface, and host raw user interface classes.
-
Building a console application that uses these host classes to build an interactive PowerShell shell.
-
Creating the $profile variable and loading the four different profiles:
- Current user, current host
- Current user, all hosts
- All users, current host
- All users, all hosts
-
Implementing the IHostUISupportsMultipleChoiceSelection interface.
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 command prompt.
- Navigate to the folder containing the sample executable.
- Run the executable.