Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
start [2026/02/18 22:54] jango |
start [2026/03/28 16:18] (aktuell) jango |
||
|---|---|---|---|
| Zeile 13: | Zeile 13: | ||
| - | <code powershell> | ||
| - | param( | ||
| - | [string]$Url = " | ||
| - | [string]$Username = " | ||
| - | [string]$Password = " | ||
| - | [int]$Count = 50, | ||
| - | [int]$DelayMs = 200 | ||
| - | ) | ||
| - | |||
| - | # Basic Auth header bauen | ||
| - | $pair = " | ||
| - | $b64 = [Convert]:: | ||
| - | |||
| - | $headers = @{ | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | } | ||
| - | |||
| - | Write-Host " | ||
| - | Write-Host " | ||
| - | Write-Host " | ||
| - | Write-Host "" | ||
| - | |||
| - | for ($i=1; $i -le $Count; $i++) { | ||
| - | $sw = [System.Diagnostics.Stopwatch]:: | ||
| - | |||
| - | try { | ||
| - | # -SkipCertificateCheck ist in PS7 verfügbar (falls ihr intern/ | ||
| - | $resp = Invoke-WebRequest -Uri $Url -Method Get -Headers $headers -MaximumRedirection 0 -SkipCertificateCheck -ErrorAction Stop | ||
| - | $code = [int]$resp.StatusCode | ||
| - | } catch { | ||
| - | # Bei 401/429 wirft Invoke-WebRequest meist eine Exception -> Code auslesen | ||
| - | $code = $null | ||
| - | if ($_.Exception.Response -and $_.Exception.Response.StatusCode) { | ||
| - | $code = [int]$_.Exception.Response.StatusCode | ||
| - | } elseif ($_.ErrorDetails -and $_.ErrorDetails.Message -match '" | ||
| - | $code = [int]$matches[1] | ||
| - | } | ||
| - | } | ||
| - | |||
| - | $sw.Stop() | ||
| - | $ts = (Get-Date).ToString(" | ||
| - | |||
| - | if ($null -eq $code) { $code = -1 } | ||
| - | |||
| - | Write-Host (" | ||
| - | |||
| - | if ($code -eq 429) { | ||
| - | Write-Host "Got 429 -> rate limit seems active. Stopping." | ||
| - | break | ||
| - | } | ||
| - | |||
| - | Start-Sleep -Milliseconds $DelayMs | ||
| - | } | ||
| - | </ | ||