Created
March 30, 2021 06:58
-
-
Save avipars/e1f07cc325fba52625b07886e28e4b76 to your computer and use it in GitHub Desktop.
Powershell detect if current IP is different than your previous one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$uri = "https://whatismyip.host/ip4" | |
$ipv4 = (Invoke-WebRequest -uri $uri).Content | |
$currentip = "your.current.public.ip4" | |
$val = $true | |
:loop while ($val) { | |
if($ipv4 -ne $currentip){ | |
Write-Output "not equal - $ipv4 vs $currentip" | |
$val = $false | |
[console]::beep(500,300) | |
break loop | |
} | |
else{ | |
Write-Output "same IP - $ipv4" | |
$val = $true | |
Start-Sleep -Seconds 500 | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$uri = "https://whatismyip.host/ip4"
#old http://ifconfig.me/ip
$ipv4 = (Invoke-WebRequest -uri $uri).Content
$currentip = "5.29.26.5"
$val = $true
$exists = $false
$powershell = "IP-whitelist\iplist.txt"
$file = Get-Content $powershell
:loop1 while ($val){
$containsWord = $file | %{$_ -match $ipv4}
if ($containsWord -contains $true) {
Write-Output "same IP - $ipv4"
$val = $true
Start-Sleep -Seconds 500
$exists = $true
$val = $true
}
<#
:loop while ($val) {
if($ipv4 -ne $currentip){
Write-Output "not equal - $ipv4 vs $currentip"
Set-Clipboard -Value $ipv4
}
#Invoke-RestMethod -Uri ('http://ipinfo.io/'+(Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
#>