Skip to content

Instantly share code, notes, and snippets.

@nichollsc81
Last active June 23, 2021 10:29
Show Gist options
  • Save nichollsc81/c93322cdbd9ed2f8818c908470f06679 to your computer and use it in GitHub Desktop.
Save nichollsc81/c93322cdbd9ed2f8818c908470f06679 to your computer and use it in GitHub Desktop.
Test certificate chain of target uri
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