Method 1:

Invoke-RestMethod -Uri ('http://ipinfo.io/'+(Invoke-WebRequest -uri "http://ifconfig.me/ip").Content)

Method 2:

function getIPGeolocation($ipAddress) {

$request = Invoke-RestMethod -Method Get -Uri "http://ip-api.com/json/$ipAddress"

[PSCustomObject]@{
IP = $request.query
City = $request.city
Country = $request.country
Isp = $request.isp
}
}

$thisPublicIP=(Invoke-WebRequest -uri "http://ifconfig.me/ip").Content
getIPGeolocation $thisPublicIP