https://github.com/evilbytecode/ps2bat
A Documentation for my module PS2BAT, it converts Powershell Scripts to Batchfile ones.
https://github.com/evilbytecode/ps2bat
Last synced: 15 days ago
JSON representation
A Documentation for my module PS2BAT, it converts Powershell Scripts to Batchfile ones.
- Host: GitHub
- URL: https://github.com/evilbytecode/ps2bat
- Owner: EvilBytecode
- Created: 2024-01-21T14:28:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-27T06:44:44.000Z (10 months ago)
- Last Synced: 2025-03-26T08:37:32.823Z (about 1 month ago)
- Language: PowerShell
- Size: 11.7 KB
- Stars: 12
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PS2BAT Module Documentation
===========================- Powershell Into Batchfile!
Overview
--------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.
## Installing Module:
```powershell
Install-Module -Name PS2BAT
```
> Make sure to run Powershell as administrator.If you don't want to install the module, you can try the direct import method (See below).
Usage
-----### Standard Module Import:
```powershell
Import-Module -Name PS2BAT -Force
Convert-PSToBAT -Path "POWERSHELL_FILE_PATH"
```
* **`-Path`:** Specifies the path to the PowerShell script file you want to convert.
### Alternative Import Method (IF PROBLEMS):
> Only for Windows PowerShell. Not for PowerShell 7.
```powershell
Import-Module -Name 'C:\Program Files\WindowsPowerShell\Modules\PS2BAT\1.0.0\PS2BAT.psm1' -Force
Convert-PSToBAT -Path "PATH_TO_PS1_FILE"
```
### Direct Import Method:
> - Works with all versions of Powershell
> - No need to install the module
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.
2. Open PowerShell in the folder of the module.
3. Then execute this:
```powershell
Import-Module -Name .\PS2BAT.psm1
Convert-PSToBAT -Path "PATH_TO_PS1_FILE"
```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.