Chapter 5. Add PowerShell to Your GUI

Adding scripting support to your application is one of the most valuable things you can do for your client, letting them add value to your software, and keep it current over time with little or no overhead from the developers.

—Roy Osherove, author and consultant (http://bit.ly/K0xClG)

When you add PowerShell to an application, other developers, end users, testers, and system integrators can customize the application’s logic to better match their specific needs. This approach is an efficient use of resources; developers can focus their efforts on core functionality while allowing others to easily and independently customize the application as they desire. Using PowerShell in this way obviates the need to distribute the application source code for other developers to extend the application. As a result, you do not need to support multiple versions of the application.

Thus, not only does adding PowerShell to an application speed software development, but it also allows for common areas of application customization such as modifying code to match particular businesses processes, automating repetitive tasks, adding unique features, and accessing internal and remote data.

Embedding PowerShell in your C# Application

PowerShell is surfaced as a command-line application (the console), a scripting language, and an API. In this section, I’ll show you the API and how simple it is to create the PowerShell engine, call some cmdlets, and print out the ...

Get Windows PowerShell for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.