Is there a verbose exact equivalent for the ‘&’ call operator to use with scriptblocks?
Like this pseudocode:
CALL { "Arguments are:"; $args; } One Two "Three word argument"
To replace:
& { "Arguments are:"; $args; } One Two "Three word argument"
EDIT:
The reason I need this is to pass batch file arguments to powershell.
This fails:
@ECHO OFF
START powershell.exe -noexit -Command "^& { \"Batch file arguments are:\"; $args; } %*"
I can do it like this, but the first method is cleaner:
@ECHO OFF
START powershell.exe -noexit -Command Invoke-Expression $('^& { \"Batch file arguments are:\"; $args; } %*')
I know I still need to escape quotes for long arguments.
Thanks.
You can pass batch file arguments to PowerShell like this:
It will escape quotes so you can call it like: