This is the approach proposed by the stackoverflow's user rojo which also can handle the command line arguments :
<# : batch portion
@echo off & setlocal
(for %%I in ("%~f0";%*) do @echo(%%~I) | ^
powershell -noprofile "$argv = $input | ?{$_}; iex (${%~f0} | out-string)"
goto :EOF
: end batch / begin powershell #>
"Result:"
$argv | %{ "`$argv[{0}]: $_" -f $i++ }
called like this:
psbatch.bat arg1 "This is arg2" arg3
will produce:
Result:
$argv[0]: C:\Users\rojo\Desktop\test.bat
$argv[1]: arg1
$argv[2]: This is arg2
$argv[3]: arg3