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

Renew or Replace a SSL Certificate in Dynamics CRM

Error Message: "Exchange Online Security Certificate Expiration Please update your certificate or Exchange Online integration…

PowerShell: Windows 10 Cleanup

Update: there's a new script to cleanup windows here. function cleanWindows{ write-host 'Disabling Windows Media…

Windows: Create a Quick Hot Spot From A Wired Computer with Spare Wireless Adapter

# Start the Hot Spot netsh wlan set hostednetwork mode=allow ssid="$env:username hotspot" key=whatpassword netsh wlan…