# PowerShell Simple Retry Logic

Contents

Well, this is quite a dirty fix for anything not stable…

First time failed? Run second time, failed? Third time again… Only exits successful or retried more than 3 times.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  $Stoploop =$false [int]$Retrycount = "0" do { try { Scripts Commands here Write-Host "Job completed"$Stoploop = $true } catch { if ($Retrycount -gt 3){ Write-Host "Could not send Information after 3 retrys." $Stoploop =$true } else { Write-Host "Could not send Information retrying in 30 seconds..." Start-Sleep -Seconds 30 $Retrycount =$Retrycount + 1 } } } While ($Stoploop -eq$false)