4 ms·
Doesn't work for me, I get: At line:1 char:16 + $loop = "loop" do {$response = $null; Start-Sleep -Seconds 5 try {$re ... + ~~ Unexpected toke
by joenathanone 6y ago
Doesn't work for me, I get:
At line:1 char:16
+ $loop = "loop" do {$response = $null; Start-Sleep -Seconds 5 try {$re ...
+ ~~
Unexpected token 'do' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
- imperialdrive 6y agoSorry about that - I have no idea how to format comments. I placed a copy here: https://www.codepile.net/pile/gz77EXzd https://www.codepile.net/pile/gz77EXzd
- joenathanone 6y agoThis version works for me, thank you :-)
- douglasrank 6y agoCleaned-up version while ($true) { $response = $null; try { $response = Invoke-WebRequest "https://login.microsoftonline.com/common/oauth2/ https://login.microsoftonline.com/common/oauth2/" -ErrorAction SilentlyContinue | select status*; if ($response) { "OK $($response.StatusCode) $(Get-Date)" | Write-Host; } } catch { "Down $(Get-Date)" | Write-Host; }; Start-Sleep -Seconds 5; }
- joenathanone 6y agoThank you, that works.
- imperialdrive 6y agoAhh, thank you. I simply dabble in PS on the side and write util-like scripts as a brain stretch. This is the first time I've ever had someone look at and 'clean' anything... much appreciated.