相关疑难解决方法(0)

如何在命令行的路径中运行带有空格的powershell脚本?

所以我尝试了一些不同的方法从命令行运行PowerShell脚本,每一个都返回一个错误.

这是这条路:

C:\Users\test\Documents\test\line space\PS Script\test.ps1
Run Code Online (Sandbox Code Playgroud)

我试过这些:

powershell -File '"C:\Users\test\Documents\test\line space\PS Script\test.ps1"'

powershell "& ""C:\Users\test\Documents\test\line space\PS Script\test.ps1"""

Powershell "& 'C:\Users\test\Documents\test\line space\PS Script\test.ps1'"

Powershell -File 'C:\Users\test\Documents\test\line space\PS Script\test.ps1'"
Run Code Online (Sandbox Code Playgroud)

我收到所有这些错误:

&:术语"C:\ Users\test\Documents\test\line space\PS Script \"不被识别为cmdlet,函数,脚本文件或可操作程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试.

处理-File''C:\ Users\test\Documents\test\line space\PS Script \''失败:不支持给定路径的格式.为-File参数指定有效路径.

任何帮助将不胜感激!

powershell scripting cmd

9
推荐指数
3
解决办法
2万
查看次数

标签 统计

cmd ×1

powershell ×1

scripting ×1