Say I have two files in a directory with angle brackets in the path (e.g. c:\foo[bar]
)
test.ps1
test.bat
In test.ps1
all I have is:
"HelloWorld"
In test.bat
I have:
powershell -file test.ps1
echo %errorlevel%
Where powershell v2 is installed, if I execute test.bat
from the command prompt, with the working directory in the foo[bar]
, I get "HelloWorld" output from the ps script but the error code 1 echoed to the console. This does not occur when the path contains no angle brackets or in instances where powershell v3 is installed ("HelloWorld" is output and 0 is returned as the error code).
This just appears to be a problem when using the powershell v2 executable with the -file
switch. My first assumption is that this is a bug, but I couldn't find anything out there on this specific problem.
Is there any workaround or solution to this?