i am writing a script to test a specific ADFS URL. (Federated Metadata). The way the script works is it firsts adds an entry to the Local computers hosts file with IP Address and Name and then uses Invoke-Webrequest to access the site and see if it responds.
this works fine, However if i provide multiple IP Addresses to test where the first IP is correct and the second IP is incorrect, Invoke web request still passes with a response of 200. although the website cannot be reached on the second IP address.
something is caching. how do i clear the Invoke-Webrequest cache
I have already tried the
-Headers @{"Cache-Control"="no-cache"}
$FederatedMetadata = Invoke-WebRequest "https://$($ADFSNameSpace)/FederationMetadata/2007-06/FederationMetadata.xml" -Headers @{"Cache-Control"="no-cache"}
if($FederatedMetadata.StatusCode -eq "200"){
Write-Host "Connection successful to https://$($ADFSNameSpace)/FederationMetadata/2007-06/FederationMetadata.xml" -ForegroundColor Green
$EXTFederatedMetadataTest = "PASS"
}#END_IF
else{
Write-Host "Connection Failed to https://$($ADFSNameSpace)/FederationMetadata/2007-06/FederationMetadata.xml" -ForegroundColor RED
$EXTFederatedMetadataTest = "FAIL"
}#END_ELSE