Get external IP



# Name: externalip.ps1
# Function: Get your external IP address
# Language: Windows PowerShell
# Author: Jimmy Johansson
# Creation: 2009-08-31
# Example: "./externalip" will return your external IP

Save the script in a text document and save it with the ps1 extension and then call it from a PowerShell prompt.


$client = new-object system.net.WebClient $client.Headers.Add("user-agent", "PowerShell") $data = $client.OpenRead("http://icanhazip.com") $reader = new-object system.io.StreamReader $data [string] $s = $reader.ReadToEnd() write-host "Your external IP is $s" $data.Close() $reader.Close()