How to use the new PS2EXE -embedFiles parameter

Written by Horatiu Vladasel · October 16th, 2025 · 3min read

Converting PowerShell scripts into standalone executables with PS2EXE has always carried one persistent inconvenience: the external files.

The new -embedFiles parameter changes the rhythm entirely. Instead of scattering dependencies, it folds them into the executable itself, a seamless fusion of script and resource.

Everything your script relies on now travels inside one unified file.

The result feels cleaner, smarter, and more portable. No stray files, no missing assets, no deployment headaches.

How it works from the command line (using PS2EXE CLI)Copy link to this sectionLink to this section copied!

In a previous article, we went through How to convert a PowerShell Script into an EXE Shortcut using PS2EXE GUI.

On the other side, you can also use PS2EXE command-line support. And here is an example of how you can use that:

ps2exe -inputfile "C:\Users\HoratiuVladasel\Desktop\AppFinder.ps1" -outputfile "C:\Users\HoratiuVladasel\Desktop\AppFinder.exe" -iconfile "C:\Users\HoratiuVladasel\Desktop\AppFinder.ico" -version "1.0.0" -product "App FInder" -noConsole

where:

  • inputFile - the path to the Powershell script that you want to convert to executable (file has to be UTF-8 or UTF-16 encoded)
  • outputFile - the path to the compiled executable, defaults to inputFile with extension '.exe'
  • iconFile - the path to the icon file for the compiled executable
  • product - product information displayed in details tab of Windows Explorer's properties dialog
  • version - version information displayed in details tab of Windows Explorer's properties dialog)
  • noConsole - the resulting executable will be a Windows Forms app without a console window

Now, starting with version 1.0.17, you can also use the -embedFiles parameter to embed files within the compiled executable. Your command line should look like the following:

ps2exe -inputfile "C:\Users\HoratiuVladasel\Desktop\AppFinder.ps1" -outputfile "C:\Users\HoratiuVladasel\Desktop\AppFinder.exe" -iconfile "C:\Users\HoratiuVladasel\Desktop\AppFinder.ico" -version "1.0.0" -product "App FInder" -noConsole -embedFiles @{'%windir%\Temp\PreReq.msi'='C:\Users\HoratiuVladasel\Desktop\PreReq.msi'}

The files to be embedded are given as a hash table:

-embedFiles @{'Targetfilepath1'='Sourcefilepath1';'Targetfilepath2'='Sourcefilepath2'}
        .
      

When the executable runs, the embedded files are written directly to disk according to the target paths you define. Some paths are absolute, pointing exactly where they should. Others are relative, adjusting based on context.

A path beginning with “.\” stays local, tied to the executable itself, while one without that prefix uses the current working directory at runtime.

Directories appear automatically if they are missing, created as the program executes. Environment variables inside those paths expand naturally, adapting to the system at that moment. If any embedded files are not created, the compiled executable is terminated immediately, ensuring consistency and preventing partial execution.

ConclusionCopy link to this sectionLink to this section copied!

The -embedFiles parameter is more than a convenience; it’s a quiet transformation of how PowerShell scripts become deployable software. It minimizes setup effort, strengthens reliability, and aligns perfectly with deployment tools such as Advanced Installer. For developers seeking consistent execution and simplified delivery, this enhancement brings clarity, precision, and a touch of sophistication to the PowerShell-to-EXE process.

Written by
See author's page
Horatiu Vladasel

Horatiu is a Software Packager/Sequencer with over 10 years experience, who has worked as a Software Packager at IBM and is currently offering software packaging services to companies such as BT or Nationwide.

Comments: