如何运行PowerShell脚本?
powershell.exe 'C:\my_path\yada_yada\run_import_script.ps1' (带或不带--noexit)它完全不返回任何内容,只是文件名是输出的。
没有错误没有消息什么都没有。哦,当我添加-noexit时,也会发生同样的事情,但我仍然在PowerShell中,必须手动退出。
.ps1文件应该运行一个程序并根据该程序的输出返回错误级别。但我很确定我还没到那里。
我做错了什么?
发布于 2010-01-09 22:24:43
前提条件:
步骤:
PS>提示符出现或者:您可以从命令提示符(cmd.exe)运行如下所示的cmd.exe脚本:
powershell -noexit "& ""C:\my_path\yada_yada\run_import_script.ps1""" (enter)据柯克·蒙罗( Kirk )报道。
或者你甚至可以从PowerShell应用程序异步运行您的C#脚本。
发布于 2010-01-09 23:39:12
如果您使用的是PowerShell 2.0,请使用PowerShell.exe的-File参数从其他环境(如cmd.exe )调用脚本。例如:
Powershell.exe -File C:\my_path\yada_yada\run_import_script.ps1发布于 2011-01-30 22:23:06
如果希望在不修改默认脚本执行策略的情况下运行脚本,则可以在启动 PowerShell时使用旁路开关。
powershell [-noexit] -executionpolicy bypass -File <Filename>https://stackoverflow.com/questions/2035193
复制相似问题