What is a good way in PowerShell to check the IP address switcher on a web server?

Problem

Our web hosting provider changes the IP address of one of the servers on which we operate. We were given the time frame when the transition will take place, but there are no exact details. Thus, checking our current poor person requires periodically updating the page in the browser to find out if we have our site.

Question

We are all programmers here, and it kills me that a manual check is required. I would know how to do this in other languages, but I want to know if there is a way to write a script in PowerShell to solve this problem. Does anyone know how I can do this?

+4
source share
2 answers

If you can warn that the page is gone or does not have the expected value, you can use the script as

$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 do { $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)) { break} } } while ($true) write-host "The website has moved" 
+3
source

This will indicate the IP address for each network adapter on your system.

 Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property IPAddress 
0
source

Source: https://habr.com/ru/post/1277632/


All Articles