【发布时间】:2018-01-27 08:45:39
【问题描述】:
所以我尝试了很多不同的方法来从命令行运行 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"'
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'"
我得到了所有这些错误:
& : 术语“C:\Users\test\Documents\test\line space\PS Script”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,如果包含路径,请验证路径是否正确,然后重试。
处理 -File ''C:\Users\test\Documents\test\line space\PS Script'' 失败:不支持给定路径的格式。为 -File 参数指定一个有效的路径。
我该如何解决这个问题?
【问题讨论】:
-
你为什么从 cmd 运行它?
标签: powershell cmd scripting