|
RE: Passing parameters to PS script and escaping spaces After playing around a bit I found this seems to work:
powershell -command "& 'c:\my script.ps1' 'c:\my folder\' 1"
Are there any other "better" ways?
"James" wrote:
> I have written a PS script which requires two parameters to be passed in: one
> folder name and one number. If I open a PS console I can execute the script
> like this:
>
> c:\myscript.ps1 "c:\my folder\" 1
>
> I am now trying to run this script from a standard cmd console like this:
>
> powershell -command c:\myscript.ps1 "c:\my folder\" 1
>
> However the quotes don't seem to work and the script thinks it is getting 3
> parameters passed.
>
> How do I launch a script and pass parameters which may include spaces? Out
> of interest, how would I launch it if the path to the script also contains a
> space, eg:
>
> "c:\my folder\myscript.ps1" "c:\my folder\" 1 |