Main Page
 The gatekeeper of reality is
 quantified imagination.

Stay notified when site changes by adding your email address:

Your Email:

Bookmark and Share
Email Notification
Running Powershell inside C# GUI
Purpose
The purpose of this tutorial is to show how you can leverage the capabilities of PowerShell from within a C# Windows Forms Application (.Net Framework 4.7.2). This tutorial also demonstrates, via extensibility, how to use a WPF (Windows Presentation Foundation) User Control inside the forms application - specifically the highly secure PasswordBox control to help with securing credentials (which is much better than using a regular textbox with a password character mask when scanning memory). The PasswordBox, although it has been around for many years, did not really enter into wide use until the release of Windows 10.

If you are considering integrating PowerShell into your C# application, you will need the System.Management.Automation DLL. The most common method to get that DLL is from NuGet. But, depending on your development system capability or restrictions you may have on that system, it may prove a challenge to locate a version that will actually work for you. Luckily, the source code of this tutorial (which you can download) has a section dedicated to troubleshooting and a novel solution for finding a compatible DLL.

Demo
The demo (screenshot provided below - click it to show a larger version), allows you to perform a wide variety of actions utilitizing PowerShell (while an optional install in Windows 7, OS releases after that all have PowerShell by default). With it, you can target your computer, or a different computer (which would need PowerShell installed) on a network. Being in a GUI, as you can see, may actually prove to be faster than using the PowerShell shell or IDE. Finally, the demo also supports impersonation (and this is where the WPF user control is used to help secure a password that may be entered); the impersonation feature allows you to restart the application using a different account than the one, for example, you may have used to log into your computer with. PowerShell, for many actions, may require the use of an account with additional permissions.

viperPS GUI


Downloads
If you just want to do a quick test of the viperPS GUI (ready to run), see the link for "viperPS GUI". Or, if you prefer to skip a lab or isolated test, you can download the tutorial's source code with the link for "viperPS Source".

Download viperPS GUI - you will need to unzip the zip file; after starting see "About / Help" for an explanation of possible actions.

Download viperPS Source - you will need to unzip the zip file; in order to view the source and how everything is setup, you should have an IDE such as Visual Studio 2017/2019 available.



About Joe
Find Out Now!