Powershell - 尝试捕捉 - 非 Powershell 错误 [英] Powershell - Try Catch - Non Powershell Errors

查看:41
本文介绍了Powershell - 尝试捕捉 - 非 Powershell 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建一个 try-catch 来捕获非 Powershell cmdlet 错误?

Is it possible to create a try-catch that catches a non-Powershell cmdlet error?

示例错误:

iperf3: error - unable to connect to server: Connection timed out

我想捕获该错误,然后尝试使用不同的服务器来实现冗余.

I want to catch that error and then try a different server for redundancy.

感谢您的帮助.

推荐答案

您可以尝试构建自己的 powershell 函数并使用throw"抛出错误;但您必须在 powershell 函数中自行识别错误

you can try to build your own powershell function and throw an error with "throw " but you have to identify the error on your own within the powershell function

这篇关于Powershell - 尝试捕捉 - 非 Powershell 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆