PS1 to exe doesn’t perform well

Welcome Forums General PowerShell Q&A PS1 to exe doesn’t perform well

Viewing 5 reply threads
  • Author
    Posts
    • #273639
      Participant
      Topics: 13
      Replies: 17
      Points: 193
      Rank: Participant

      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.0

      Admin privileges activated.

      please help

      • This topic was modified 1 month, 3 weeks ago by Atx750k.
    • #273732
      Senior Moderator
      Topics: 10
      Replies: 202
      Points: 1,101
      Helping Hand
      Rank: Community Hero

      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.

    • #273747
      Participant
      Topics: 10
      Replies: 201
      Points: 987
      Helping Hand
      Rank: Major Contributor

      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.

      http://www.powertheshell.com/

       

       

    • #273894
      Participant
      Topics: 13
      Replies: 17
      Points: 193
      Rank: Participant

      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.
    • #273906
      Participant
      Topics: 9
      Replies: 706
      Points: 2,837
      Helping Hand
      Rank: Community Hero

      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

    • #273999
      Participant
      Topics: 13
      Replies: 17
      Points: 193
      Rank: Participant

      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!

Viewing 5 reply threads
  • You must be logged in to reply to this topic.