我想在 Powershell 中的 .exe 上做一个 Try Catch,我的样子是这样的:
Try
{
$output = C:\psftp.exe ftp.blah.com 2>&1
}
Catch
{
echo "ERROR: "
echo $output
return
}
echo "DONE: "
echo $output
当我使用无效域时,它会返回一个错误,psftp.exe : Fatal: Network error: Connection refused
但我的代码没有捕捉到它。
我将如何捕捉错误?