Embed PowerShell scripts inside batch scripts (.cmd/.bat)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE.txt
README.md
example.ps1
example.ps1.cmd
ps2cmd.cmd
ps2cmd.ps1

README.md

Embed PowerShell scripts inside batch scripts (.cmd/.bat)

:: Call ps2cmd.cmd with the filename of the PowerShell script to convert
ps2cmd.cmd example.ps1
:: A example.ps1.cmd will be created

Example

With a PowerShell script example.ps1:

Write-Host Hello World!

We run ps2cmd:

> ps2cmd.cmd example.ps1

And get example.ps1.cmd:

SET PS2CMD_ARGS=%* & PowerShell.exe -NoProfile -EncodedCommand VwByAGkAdABlAC0ASABvAHMAdAAgACQAZQBuAHYAOgBQAFMAMgBDAE0ARABfAEEAUgBHAFMAOwAgAGYAdQBuAGMAdABpAG8AbgAgAHMAdABlAHAAMgAgAHsAIABXAHIAaQB0AGUALQBIAG8AcwB0ACAASABlAGwAbABvACAAVwBvAHIAbABkACEADQAKACAAfQANAAoAcwB0AGUAcAAyACAAJABlAG4AdgA6AFAAUwAyAEMATQBEAF8AQQBSAEcAUwA=

Usages

Used in Nerven.Bygge to get the complete setup script in a single, easily executable, script file.

License

The MIT License (MIT) (see LICENSE.txt)