如果我创建一个计划任务,启动这样的Powershell脚本:
Powershell -command "& 'C:\test.ps1'"
如何在不中断-command
参数的参数中输入路径参数?
Powershell -command "& 'C:\test.ps1 -path C:\Program Files(x86)\test'"
无效,因为找不到"C:\Program"
Powershell -command "& 'C:\test.ps1 -path 'C:\Program Files(x86)\test''"
or
Powershell -command "& 'C:\test.ps1 -path "C:\Program Files(x86)\test"'"
不起作用,因为包装路径的引号会中断-command
参数
答案 0 :(得分:1)
使用-File
参数代替-Command
Powershell -File C:\script.ps1 -path C:\test