In most scenarios it's enough to use the PowerShell script as is.

But

  1. sometimes there is some sensitive data in the script you don't want to expose
  2. the executable is run hidden (doesn't show the script on the screen while logging in)


To turn a PowerShell script into an Executable

  1. Open a PowerShell window (in Administrator mode)

  2. Run
    Install-Module ps2exe


  3. Run
    Invoke-PS2EXE C:\ProgramData\Cameyo\StartupBefore.ps1 C:\ProgramData\Cameyo\StartupBefore.exe

  4. In the case of a startup script, don't forget to remove the PowerShell script, otherwise the script will be executed twice