【发布时间】:2011-01-03 08:38:12
【问题描述】:
如何运行 PowerShell 脚本?
- 我有一个名为 myscript.ps1 的脚本
- 我已安装所有必要的框架
- 我设置了execution policy 的东西
- 我已按照this MSDN help page 上的说明进行操作
并试图像这样运行它:
powershell.exe 'C:\my_path\yada_yada\run_import_script.ps1'(有或没有--noexit)
除了输出文件名外,什么都不返回。
没有错误,没有消息,什么都没有。哦,当我添加-noexit 时,也会发生同样的事情,但我仍然在 PowerShell 中,必须手动退出。
.ps1 文件应该运行一个程序并根据该程序的输出返回错误级别。但我很确定我还没有到达那里。
我做错了什么?
【问题讨论】:
-
启动
powershell,就像您启动cmd一样。现在您可以将myscript.ps1脚本作为其中的任何可执行文件执行(在powershell 窗口中),即.\myscript.ps1
标签: windows powershell scripting