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.
This topic is 6 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Squidge123
Posts: 4
Last visit: Mon Mar 04, 2024 10:08 am

Forcing Powershell GUI .exe to run under version 2

Post by Squidge123 »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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.
This topic is 6 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked