Our web host provider is changing the IP address of one of the servers we are on. We have been given a time frame for when the switch will take place, but no exact details. Therefore, our current poor man’s check requires a periodic page refresh on a browser to see if our website is still there.
We are all programmers here and this is killing me that any manual checking is required. I would know how to do this in other languages, but want to know if there is a way to write a script in PowerShell to tackle this problem. Does anyone know how I might going about this?
If you can alert if the page is gone or does not have an expected value, you could use a script like
$ip = 192.168.1.1
$webclient = new-object System.Net.WebClient
$regex = 'regular expression to match something on your page'
$ping = new-object System.Net.NetworkInformation.Ping
$result = $ping.Send($ip)
if ($result.status -ne 'TimedOut' )
$page = $webclient.downloadstring("http://$ip")
if (($page -notmatch $regex) -or ($page -match '404') -or ($page -eq $null))
} while ($true)
write-host "The website has moved"