“ -ErrorAction Stop”在尝试/捕获中不起作用

时间:2019-01-30 15:22:59

标签: powershell error-handling

昨天工作正常。

try {
    tabadmin ziplogs -f -p -a -l -n -ErrorAction Stop
} catch {
    backupemail
    [System.Environment]::Exit(1)
}

今天,当我运行此命令时,它会弹出“将日志文件压缩到特定文件”并列出所有可能的命令选项。我已经指出了-f -p -a -l

如果我有意将ziplog更改为“ zipylooog”,它将指出该错误并且没有发送电子邮件。

如果我摆脱了-ErrorAction Stop,它将运行完美。

0 个答案:

没有答案