Windows_PowerShell_iconpo  komentarzach na FB, zamieszczam prosty skrypt, który pozwala odpytać dwóch różnych stron – whatsmyipaddress, API, które zwraca czysty adres, ale ponieważ:

You may programmatically query that server but limit queries to no more than once per five minutes and include an appropriate user agent that will allow us to contact you if needed

dodałem starą metodę przegrzebującą się przez HTML.

get-ExternalIP.ps1

param( [switch]$alternateServer )

if($alternateServer) {
    $page=Invoke-WebRequest http://whatismyipaddress.com/pl/moj-ip
    [regex]$rxIP='((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
    $page.AllElements|? id -eq 'section_left'|%{ $IP=$rxIP.Match($_.outerText)}
} else {

    $result=Invoke-WebRequest ipv4bot.whatismyipaddress.com
    $IP=$result.content
}

Write-Host -BackgroundColor DarkYellow -ForegroundColor Black "EXTERNAL IP ADDRESS OF THE CONNECTION: $IP"

eN.

-o((:: sprEad the l0ve ::))o-

Zostaw komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *

Time limit is exhausted. Please reload CAPTCHA.