Posted On May 21, 2020

PowerShell: Resolving URL to Public IP

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Resolving URL to Public IP
# 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

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Update Local Windows Using COM Objects – Legacy Compatible

Although this function requires 'interactive' or console sessions, it can be trigged by Windows Scheduled…

HTML: Tagging and Jumping to Sections of Page

Each element of an HTML document could be set with a unique ID so that…

HAProxy Example for SSH & OpenVNP forwarding

# Source: https://limbenjamin.com/articles/running-https-ssh-vpn-on-port-443.html   global tune.ssl.default-dh-param 2048   defaults timeout connect 5000 timeout client 50000 timeout…