I want it to exit when the response status code is 429, how can I do it? my looped ps1 script I don't want to use do or try or catch methods. Is there a simple method? this is my code and i want it to exit when response code 429
'header' = 'header'}
"@
$req = @{
Uri = 'https://mywebsite.com/api/'
Headers = $headers
Method = 'get'
ContentType = 'application/json'}
while($true){
Invoke-WebRequest @req
status code 429 = exit}