I have a batch file that runs a powershell script and I need to pass two parameters to the script. In my batch it looks like this:
powershell -executionpolicy remotesigned -File "my script.ps1" "my path1\" "my path2\somefile.txt"
The way it is now, the parameters for my powershell script get completely messed up and I get:
- my path1" my
I tried encapsulating my params with
` characters and I nearly got what I want, but the second quote character remains in the powershell script. What I get is this:
powershell -executionpolicy remotesigned -File "my script.ps1" "'my path1\'" "'my path2\somefile.txt'"
- 'my path1\'
- 'my path2\somefile.txt'
And what I want is this
- my path1\
- my path2\somefile.txt
I know I can strip the redundant quotes in the powershell script, but is there a better way to do this? In other words, how can I pass those parameters to the powershell in a way that keeps them sane?
Test powershell script:
echo $args echo $args