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
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=
Used in Nerven.Bygge to get the complete setup script in a single, easily executable, script file.
The MIT License (MIT) (see LICENSE.txt)