I have a simple PS script that needs to accept a parameter that happens to be a path to a directory. I get this path handed to me and invoke the ps script as follows:
powershell.exe -ExecutionPolicy Bypass -F "C:\temp\ctest\logging test\postinstall.ps1" "C:\temp\ctest\logging test\"
I cannot control the addition of the ‘\’ to the path that is the param to this script, and it must be double-quoted to account for the space in the path. So, what I wind up with is a variable inside my ps script that is the string:
C:\temp\ctest\logging test" <<-- error in path! with the double-quote char. :(
My question is simple, I hope, yet I cannot locate anyone who has solved it, yet. Is there no way to tell powershell not to escape that last double-quote in this scenario?
Thank you for your time, and for educating me.
The issue looks to be only when invoked from CMD. In your script you could do this:
It will remove a trailing double quote if one exists.
Or you could double up the backslash:
Contents of echo.ps1