Building a GUI using Windows Forms

The first option that we will discuss is Windows Forms. To utilize Windows Forms, we first need to load the respective assemblies. We can load the assemblies by using the following techniques:


Alternatively, we can use the following technique:

Add-Type -AssemblyNameSystem.Windows.Forms
Add-Type -AssemblyNameSystem.Drawing

Once the assemblies are loaded, we need to load the visual styles method as well. We can load the module by using the following method:

[void] [System.Windows.Forms.Application]::EnableVisualStyles()

I prefer using [void] to add the assemblies ...

Get Mastering PowerCLI now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.