$ErrorActionPreference = "Stop"; $tcpClient = new-object Net.Sockets.TcpClient; $tcpClient.Connect("fuat.xxx.com", 801); echo "success"

 

参考资料:

https://stackoverflow.com/questions/9948517/how-to-stop-a-powershell-script-on-the-first-error?noredirect=1

https://www.saotn.org/powershell-return-value-exit-code-or-errorlevel-equivalent/

https://4sysops.com/archives/stop-or-exit-a-powershell-script-when-it-errors/

https://segmentfault.com/a/1190000007727032

 

相关文章:

  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2021-10-18
  • 2021-10-24
猜你喜欢
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案