Skip to content

Instantly share code, notes, and snippets.

@ZackStone
Created August 20, 2024 22:18
Show Gist options
  • Save ZackStone/3cac5ef94f7097ba5524d525b2166d97 to your computer and use it in GitHub Desktop.
Save ZackStone/3cac5ef94f7097ba5524d525b2166d97 to your computer and use it in GitHub Desktop.
$previp = "";
while ($true)
{
$timestamp = (Get-Date -Format "HH:mm:ss");
$ip = (Invoke-WebRequest https://meuip.com/api/meuip.php).Content ;
$print = "$($timestamp): $($ip)";
#Write-Host $print;
if ($ip -ne $previp)
{
$print | Out-File -FilePath .\meuip.txt -Append;
$previp = $ip;
Write-Host "!! MUDOU !!";
Write-Host $print;
Start-Sleep 1;
}
else
{
Start-Sleep 5;
}
}
@ZackStone
Copy link
Author

Motivação: detectar mudanças de IP externo, seja por alteração de rede Wi-Fi, mudança de dispositivo primário, gerenciamento do provedor, etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment