Powershell - Try Catch - Non Powershell Errors

江枫思渺然 提交于 2021-02-11 13:20:52

问题


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

Example 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.

Thank you for the assist.


回答1:


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



来源:https://stackoverflow.com/questions/63898608/powershell-try-catch-non-powershell-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!