This simple sample code can be used to create beautiful user interface in your PowerShell script.

Running SP scripts utilizing WPF forms on machines with only PowerShell version 2, one has to specify the -STA argument to start the PowerShell process as Single Threaded Apartment. This is the default in version 3 of PowerShell.

powershell.exe -Version 2 -STA -Noprofile -ExecutionPolicy Bypass “.\PSWPFExample.ps1”