Forcing Powershell GUI .exe to run under version 2

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Posts: 1
Joined: Fri Nov 25, 2016 6:59 am

Forcing Powershell GUI .exe to run under version 2

Post by Squidge123 » Sat Jul 15, 2017 7:39 pm

I work in a mixed Sharepoint environment where I have developed a number of GUI utilities for use by the Operations team. A stumbling block has always been that a packaged .exe file will not run in our Sharepoint 2010 environment when it is necessary to load the Sharepoint snapin. This seems to be because the host always defaults to the highest version of Powershell. Whatever I have tried to overcome this limitation up to this point has proved useless. As a result, I have to package/deploy as a .PS1 file. I would rather the Operations team not have access to alter the script itself.

Is there any way to force a packaged executable to run on a specific (i.e. Lower) version of Powershell? On our Sharepoint farms versions higher than 2010 this is not a problem.

User avatar
Posts: 12258
Joined: Tue May 22, 2007 9:57 am

Re: Forcing Powershell GUI .exe to run under version 2

Post by jvierra » Sun Jul 16, 2017 1:15 am

You cab set the target version of the engine in the settings for your build. "Deploy" tab, "Packager" "Settings". Select Engine for V2 host.

To force forms to be built for V2 engine set the platform settings (Home tab) to build for V2 - 64 bit.