Kali Linux

PS2EXE : Module To Compile Powershell Scripts To Executables

PS2EXE is a Module To Compile Powershell Scripts To Executables. Overworking of the great script of Ingo Karstein with GUI support. The GUI output and input is activated with one switch, real windows executables are generated. With Powershell 5.x support and graphical front end.

Module version.

You find the script based version here (https://github.com/MScholtes/TechNet-Gallery) and here: PS2EXE-GUI: “Convert” PowerShell Scripts to EXE Files with GUI.

Author: Markus Scholtes

Version: 1.0.10

Date: 2021-04-10

Installation

PS C:> Install-Module ps2exe

(on Powershell V4 you may have to install PowershellGet before) or download from here: https://www.powershellgallery.com/packages/ps2exe/.

Usage

Invoke-ps2exe .\source.ps1 .\target.exe

or

ps2exe .\source.ps1 .\target.exe

compiles “source.ps1” into the executable target.exe (if “.\target.exe” is omitted, output is written to “.\source.exe”).

or start Win-PS2EXE for a graphical front end with

Win-PS2EXE

Parameter

ps2exe [-inputFile] ” [[-outputFile] ”] [-prepareDebug]
[-x86|-x64] [-lcid ] [-STA|-MTA] [-noConsole] [-UNICODEEncoding]
[-credentialGUI] [-iconFile ”] [-title ”] [-description ‘<description>’]<br /> [-company ‘<company>’] [-product ‘<product>’] [-copyright ‘<copyright>’] [-trademark ‘<trademark>’]<br /> [-version ‘<version>’] [-configFile] [-noOutput] [-noError] [-noVisualStyles] [-requireAdmin]<br /> [-supportOS] [-virtualize] [-longPaths]</p>

inputFile = Powershell script that you want to convert to executable (file has to be UTF8 or UTF16 encoded)
outputFile = destination executable file name or folder, defaults to inputFile with extension ‘.exe’
prepareDebug = create helpful information for debugging
x86 or x64 = compile for 32-bit or 64-bit runtime only
lcid = location ID for the compiled executable. Current user culture if not specified
STA or MTA = ‘Single Thread Apartment’ or ‘Multi Thread Apartment’ mode
noConsole = the resulting executable will be a Windows Forms app without a console window
UNICODEEncoding = encode output as UNICODE in console mode
credentialGUI = use GUI for prompting credentials in console mode
iconFile = icon file name for the compiled executable
title = title information (displayed in details tab of Windows Explorer’s properties dialog)
description = description information (not displayed, but embedded in executable)
company = company information (not displayed, but embedded in executable)
product = product information (displayed in details tab of Windows Explorer’s properties dialog)
copyright = copyright information (displayed in details tab of Windows Explorer’s properties dialog)
trademark = trademark information (displayed in details tab of Windows Explorer’s properties dialog)
version = version information (displayed in details tab of Windows Explorer’s properties dialog)
configFile = write config file (.exe.config)
noOutput = the resulting executable will generate no standard output (includes verbose and information channel)
noError = the resulting executable will generate no error output (includes warning and debug channel)
noVisualStyles = disable visual styles for a generated windows GUI application (only with -noConsole)
requireAdmin = if UAC is enabled, compiled executable run only in elevated context (UAC dialog appears if required)
supportOS = use functions of newest Windows versions (execute [Environment]::OSVersion to see the difference)
virtualize = application virtualization is activated (forcing x86 runtime)
longPaths = enable long paths ( > 260 characters) if enabled on OS (works only with Windows 10)

A generated executable has the following reserved parameters:

-debug Forces the executable to be debugged. It calls “System.Diagnostics.Debugger.Launch()”.
-extract: Extracts the powerShell script inside the executable and saves it as FILENAME.
The script will not be executed.
-wait At the end of the script execution it writes “Hit any key to exit…” and waits for a key to be pressed.
-end All following options will be passed to the script inside the executable.
All preceding options are used by the executable itself and will not be passed to the script.

R K

Recent Posts

Install VirtualBox on Ubuntu 18.04 from the Oracle Repository

VirtualBox is a free, open-source, cross-platform virtualization application maintained by Oracle. It lets you run multiple…

2 hours ago

Install PostgreSQL on Ubuntu 18.04 with Remote Access Setup

PostgreSQL (also called Postgres) is a free, open-source, object-relational database management system with a strong reputation…

2 hours ago

Install VMware on Ubuntu 18.04: Workstation Player Setup Guide

VMware Workstation Player is a mature, stable virtualization platform that lets you run multiple isolated operating…

3 hours ago

Set Up a UFW Firewall on Ubuntu 18.04: Allow, Deny, and Manage

A properly configured firewall is one of the most important layers of security for any internet-facing server. UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules that ships pre-installed on Ubuntu. Its defaults are sensible: block all incoming connections, allow all outgoing connections. No outside traffic reaches your server unless you explicitly open a port. This guide covers how to configure a UFW firewall on Ubuntu 18.04, from setting default policies and application profiles to writing allow and deny rules for specific ports, IPs, and subnets. <strong>Prerequisite:</strong>&nbsp;You&nbsp;need&nbsp;sudo&nbsp;access. Configure UFW Firewall on Ubuntu: Defaults, SSH, and Application Profiles If UFW is not installed, add it with: bashsudo…

3 hours ago

Disable UFW Firewall on Ubuntu 18.04: Stop, Reset, and Re-enable

UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules on Ubuntu. It ships pre-installed…

3 hours ago

Install Apache Cassandra on Ubuntu 18.04: NoSQL Setup Guide

Apache Cassandra is a free, open-source NoSQL database designed for high availability and linear scalability with…

1 day ago