Welcome › Forums › General PowerShell Q&A › PS1 to exe doesn’t perform well
- This topic has 5 replies, 4 voices, and was last updated 1 month, 3 weeks ago by
Participant.
-
AuthorPosts
-
-
November 24, 2020 at 5:05 am #273639
Hello,
I have a script which should be running on dozens computers at the first time,
so I need to Set-ExecutionPolicy Unrestricted before I run it. I’ve just added the following line at the top of the script:Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force
or:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Confirm:$false
work great within the ISE, nothing happens when converting it to .exe
what I used to convert to .exe:
# import module
Install-Module -Name Sorlov.PowerShell# export to .exe file
New-SelfHostedPS -SourceFile C:\path\to\file.ps1 -DestinationFile C:\path\to\export.exe -HideConsole -IconPath C:\path\to\icon.ico -Version 2.0.0.0Admin privileges activated.
please help
-
This topic was modified 1 month, 3 weeks ago by
Atx750k.
-
This topic was modified 1 month, 3 weeks ago by
-
November 24, 2020 at 10:27 am #273732
I’m not sure about converting to .exe, but you shouldn’t count on ISE as a test environment. The shell inside ISE isn’t the same as the actual PowerShell runtime; rather, it is an emulation of a console packaged inside a GUI app. There are significant differences in the way ISE executes cmdlets and the way PowerShell itself executes them.
On top of that, ISE development has ended. Windows PowerShell v5.1 was the last version supported in ISE, but if your system is up to date you should be using PowerShell Core v7+.
So, you need to test your script either in VSCode or in the shell itself before trying to use it in your production environment. Testing done in ISE is not valid.
-
November 24, 2020 at 10:37 am #273747
Have a look at ISE Steroids. Not free, but I have used it for a long time now to convert to EXE with no issues.
-
November 25, 2020 at 12:15 am #273894
ws PowerShell v
Thanks for your reply.
so what tool is the most suggested to create PowerShell scripts now?
I used to work with Visual Studio with the PowerShell extension and looking but it was still not comfortable as the ISE for me
-
This reply was modified 1 month, 3 weeks ago by
Atx750k.
-
This reply was modified 1 month, 3 weeks ago by
-
November 25, 2020 at 12:36 am #273906
Regardless of all that if you have to change the execution policy in order to run a script you can’t run a script to change the execution policy. You’ll have to change it ahead of time or call powershell executable with -executionpolicy parameter
-
November 25, 2020 at 4:43 am #273999
Regardless of all that if you have to change the execution policy in order to run a script you can’t run a script to change the execution policy. You’ll have to change it ahead of time or call powershell executable with -executionpolicy parameter
yes, that’s the best for me, worked great, thanks!
-
-
AuthorPosts
- You must be logged in to reply to this topic.