invoke-remote.ps1 506 B

123456789101112
  1. param([Parameter(ValueFromRemainingArguments=$true)][string[]]$Command)
  2. $ErrorActionPreference='Stop'
  3. $delays=2,5,10,20,30
  4. $knownHosts=Join-Path $HOME '.ssh\known_hosts'
  5. for($i=0;$i -lt $delays.Count;$i++){
  6. & ssh -o StrictHostKeyChecking=yes -o "UserKnownHostsFile=$knownHosts" `
  7. -o ConnectTimeout=10 -o ServerAliveInterval=15 -o ServerAliveCountMax=4 `
  8. edk2-uefi-lab @Command
  9. if($LASTEXITCODE -eq 0){exit 0}
  10. if($i -eq 4){throw 'REMOTE_NETWORK_UNSTABLE'}
  11. Start-Sleep -Seconds $delays[$i]
  12. }