Get-MyIP.ps1
<#PSScriptInfo .VERSION 1.1 .GUID 98ac9b45-bbdd-499f-844a-6f00d3ce86ad .AUTHOR saw-friendship .COMPANYNAME .COPYRIGHT saw-friendship .TAGS IP .LICENSEURI .PROJECTURI https://sawfriendship.wordpress.com/2016/03/01/powershell-get-myip/ .ICONURI .EXTERNALMODULEDEPENDENCIES .REQUIREDSCRIPTS .EXTERNALSCRIPTDEPENDENCIES .RELEASENOTES #> <# .DESCRIPTION Get you External IP address #> param( [ValidateRange(0,10)][int]$TimeoutSec = 4, [ValidatePattern("^(http)(s)*\:\/\/")][string[]]$Sites = @( "http://myexternalip.com/raw", "https://api.ipify.org/", "http://www.findmyip.org/", "http://checkip.dyndns.org", "http://myip.ru/", "http://internet.yandex.ru/", "http://2ip.ru/" ) ) foreach ($Site in $($Sites | Get-Random -Count $Sites.count)) { Write-Progress -Activity "Invoke-WebRequest" -Status $Site try{ $IP = ((Invoke-WebRequest -URI $Site -TimeoutSec $TimeoutSec) | Select-String "(((\d){1,3}\.){3}(\d){1,3})").Matches.Value } catch{} if($IP -as [ipaddress]){break} } $IP |