Wrapping A PowerShell-Script Call In A Batchfile
Yet another opinion on this topic, YAY!
As I wasn’t satisfied with the most common solutions out there (first 5 google hits) – I’ve decided to create a .ps1->.bat wrapper on my own:
@echo off setlocal enableextensions enabledelayedexpansion set psscript="path_to_your_script" echo ================================================== echo ============= WRAP POWERSHELL SCRIPT ============= echo ================================================== echo calling %psscript% with args %* PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%psscript%' %*" echo ================================================== endlocal
Why did I create another version of the very same thing that should be well known already? – because I wanted to pass all arguments/parameters that are passed to the .bat-File to the wrapped PowerShell script:
Update: of course this also works with ‘BoundParameters’ 🙂
If you don’t like it – have a look at those alternatives: