Last active
June 23, 2021 10:29
-
-
Save nichollsc81/c93322cdbd9ed2f8818c908470f06679 to your computer and use it in GitHub Desktop.
Test certificate chain of target uri
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-PactEndpoint | |
{ | |
[cmdletbinding()] | |
param ( | |
[Parameter(Position=0)] | |
[string] $Uri, | |
[Parameter(Position=1)] | |
[int] $Retrycount = '3' | |
) | |
$Stoploop = $false | |
do | |
{ | |
try | |
{ | |
$request = [System.Net.WebRequest]::Create($Uri) | |
$response = $request.GetResponse() | |
#$response.StatusCode | |
Write-Host 'PACT broker endpoint available' | |
if ($response.StatusCode -eq 'OK') | |
{ | |
$Stoploop = $true | |
} | |
} | |
catch | |
{ | |
if ($Retrycount -gt 3) | |
{ | |
Write-Error 'Could not send Information after 3 retrys.' | |
$Stoploop = $true | |
} | |
else | |
{ | |
Write-Warning 'Could not send Information retrying in 30 seconds...' | |
Start-Sleep -Seconds 30 | |
$Retrycount = $Retrycount + 1 | |
} | |
} | |
finally | |
{ | |
if($response) | |
{ | |
$response.Close() | |
} | |
} | |
} | |
while ( | |
$Stoploop -eq $false | |
) | |
} | |
#Test-PactEndpoint 'http://apppactbroker.moneycorp.local:1234' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment