Quantcast
Channel: Rob V IT
Viewing all articles
Browse latest Browse all 64

Get external IP Address using PowerShell

$
0
0

In some cases it can be useful to check your external IP Address within a PowerShell script.
So I created this little script:

$content = Invoke-WebRequest -Uri http://myip.world
$co = $content.RawContent.split()
$regex = [regex] "\b(?:(?: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]?)\b"
$ip = $regex.Matches($co) | %{ $_.value }

$ip


Viewing all articles
Browse latest Browse all 64

Trending Articles