# URL can be with http, https, full paths, or just domain
$url='https://google.com/domains'
# This will return the position 0 public IP of the provided URL's domain
$regexDomain='(http[s]:\/{2}){0,1}([\d\w\.-]+)\/{0,1}'
$domain=.{[void]($url -match $regexDomain);$matches[2]}
$publicIP=[System.Net.Dns]::GetHostAddresses($domain)[0].IPAddressToString
write-host $publicIP
Categories: