send web requests to list of URLs belonging to a particular website or server

Requires powershell v3

This script will ignore tls/trust issues that you may be having. You can also take out that part of your script if you keep receiving the error:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
At Line: Char:

#usage: urlwarmup.ps1 -server [servername]
#for questions, email csmith@avari.tech
param (
[string]$server = "serverName"
)
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
$warmupURLS = "https://$server.advocare.com/",`
"https://$server.com/store",`
"https://$server.com/store/item1",`
"https://$server.com/",`
"https://$server.com/api/en/productsapi/getallproducts/false/false/false/false/false"

foreach ($url in $warmupURLS){
$request = Invoke-WebRequest -URI $url -Method GET -TimeoutSec 200
if ($request.StatusCode -eq "200"){write-host "successful request to $url"}
else{write-host "request to $url failed"}
} 

Leave a Reply

Your email address will not be published. Required fields are marked *