functions/Private/ErrorHandling/Trace-MgaThrottle.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function Trace-MgaThrottle {
    param (
        $Seconds
    )
    try {
        $RetryValue = 0
        [int]$RetryValue = $Seconds
        if ($RetryValue -eq 0) {
            $RetryValue = 15  
        }
        elseif ($RetryValue -eq 1) {
            $RetryValue = 15  
        }
        elseif ([string]::IsNullOrEmpty($RetryValue)) {
            $RetryValue = 15 
        }
        Write-Warning "Trace-MgaThrottle: Throttled for $RetryValue seconds"
        Start-Sleep -Seconds $($RetryValue + 1)
    }
    catch {
        throw $_
    }
}