PowerShell Try/Catch and Retry

前端 未结 4 2014
故里飘歌
故里飘歌 2020-12-31 07:22

I have a fairly large powershell scripts with many (20+) functions which perform various actions.

Right now all of the code doesn\'t really have any error handling

4条回答
  •  鱼传尺愫
    2020-12-31 07:44

    Error handling is always going to add more to your script since it usually has to handle many different things. A Try Catch function would probably work best for what you are describing above if you want to have each function have multiple tries. A custom function would allow you to even set things like a sleep timer between tries by passing in a value each time, or to vary how many tries the function will attempt.

提交回复
热议问题