├── PS2BAT.psd1 ├── PS2BAT.psm1 ├── LICENSE └── README.md /PS2BAT.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | ModuleVersion = '1.0.0' 3 | Author = 'Codepulze' 4 | Description = 'Converts PowerShell Code into Batch file using Encoded Method' 5 | PowerShellVersion = '5.1' 6 | FunctionsToExport = 'Convert-PSToBAT' 7 | GUID = 'afef31f5-da59-437e-b7af-941368245251' 8 | } 9 | -------------------------------------------------------------------------------- /PS2BAT.psm1: -------------------------------------------------------------------------------- 1 | function Convert-PSToBAT { 2 | param ( 3 | [string]$Path 4 | ) 5 | 6 | process { 7 | if (-not $Path -or -not (Test-Path -Path $Path)) { 8 | Write-Host "Invalid path: $Path" 9 | return 10 | } 11 | 12 | $encoded = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes((Get-Content $Path -Raw -Encoding UTF8))) 13 | "@echo off`npowershell.exe -NoExit -encodedCommand $encoded" | Set-Content "$Path.bat" -Encoding Ascii 14 | } 15 | } 16 | 17 | Export-ModuleMember -Function Convert-PSToBAT -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 EvilBytecode 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to use the Software for educational and authorized cybersecurity research purposes only, subject to the following conditions: 7 | 8 | The above copyright notice, this permission notice, and the following disclaimer shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS (INCLUDING EvilBytecode) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 12 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE, COPYING, DOWNLOADING, OR OTHER DEALINGS IN THE SOFTWARE. 13 | 14 | DISCLAIMER: I, EvilBytecode, release this project strictly for educational, academic, and authorized cybersecurity research purposes. 15 | By accessing, downloading, copying, using, or modifying this software, you agree to these terms. 16 | You must obtain explicit written permission from system owners before conducting any testing using this software. 17 | Unauthorized use, distribution, or deployment of this software against any third party, device, network, or system without prior consent is strictly forbidden and illegal. 18 | I, EvilBytecode, disclaim all responsibility, liability, or consequences arising from any misuse, illegal activities, damages, or losses resulting from this software. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PS2BAT Module Documentation 2 | =========================== 3 | 4 | 5 | - Powershell Into Batchfile! 6 | 7 | Overview 8 | -------- 9 | 10 | The PS2BAT module provides a cmdlet called `Convert-PSToBAT`, allowing users to convert PowerShell scripts (`*.ps1` files) into batch files (`*.bat` files). This can be useful for scenarios where running PowerShell scripts might be restricted, and a batch file serves as a workaround. 11 | 12 | ## Installing Module: 13 | ```powershell 14 | Install-Module -Name PS2BAT 15 | ``` 16 | > Make sure to run Powershell as administrator. 17 | 18 | If you don't want to install the module, you can try the direct import method (See below). 19 | 20 | Usage 21 | ----- 22 | 23 | ### Standard Module Import: 24 | ```powershell 25 | Import-Module -Name PS2BAT -Force 26 | Convert-PSToBAT -Path "POWERSHELL_FILE_PATH" 27 | ``` 28 | 29 | 30 | * **`-Path`:** Specifies the path to the PowerShell script file you want to convert. 31 | 32 | ### Alternative Import Method (IF PROBLEMS): 33 | > Only for Windows PowerShell. Not for PowerShell 7. 34 | ```powershell 35 | Import-Module -Name 'C:\Program Files\WindowsPowerShell\Modules\PS2BAT\1.0.0\PS2BAT.psm1' -Force 36 | Convert-PSToBAT -Path "PATH_TO_PS1_FILE" 37 | ``` 38 | 39 | ### Direct Import Method: 40 | > - Works with all versions of Powershell 41 | > - No need to install the module 42 | 1. Make sure your [Execution Policy](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4) is compatible. 43 | 2. Open PowerShell in the folder of the module. 44 | 3. Then execute this: 45 | ```powershell 46 | Import-Module -Name .\PS2BAT.psm1 47 | Convert-PSToBAT -Path "PATH_TO_PS1_FILE" 48 | ``` 49 | 50 | Users can use alternative import methods if they encounter issues with the standard module import. Make sure to provide the correct path to the `PS2BAT.psm1` file and the PowerShell script file you want to convert. 51 | 52 | 53 | ## License 54 | This project is licensed under the MIT License. See the LICENSE file for details. --------------------------------------------------------------------------------