【发布时间】:2012-12-07 11:15:09
【问题描述】:
我在执行 powershell 脚本时遇到了一些奇怪的行为。
- 当我使用 ISE 运行我的脚本时,它运行良好。
- 当我打开 Powershell.exe 并运行我的脚本时,它运行良好。
- 当我打开 cmd 并使用
powershell.exe -noexit ./myscript.ps1启动我的脚本时,myscript 工作正常。
但是,当我双击 myscript 时,powershell 打开了几毫秒,我看到它显示了一些错误(红色字体)并且 powershell 窗口关闭了。由于 powershell 窗口关闭得很快,我无法找到导致此问题的错误。
我什至在我的洞脚本周围尝试了一个大的 try-catch 块,捕获任何 [Exception] 并将其写入日志文件。但是:没有生成日志文件(没有调用catch)。
如何跟踪该问题?什么可能导致麻烦? 请注意,我的执行策略设置为不受限制。
【问题讨论】:
标签: powershell command-line powershell-3.0