Param(
[string]$foo,
)
./Powershellscript.ps1 -foo "Bar1 bar2/ Bar3/Bar4"
When I ran the above as a scheduled task the output I would get for $foo is Bar1 bar2/ Bar3
When I ran the below as a scheduled task ( Single Quotes ) the output I would get for $foo is Bar1 bar2/ Bar3/Bar4 (Correct )
./Powershellscript.ps1 -foo 'Bar1 bar2/ Bar3/Bar4'
So why?
When you run powershell.exe from inside Powershell you are forcing the arguments to go through the old Windows style command line processing.
This way all of the arguments will pass right through without being converted to strings, having double quotes stripped and then being re-parsed.