Get-NameFromIP.ps1 demonstrates two functions which I use frequently:
Function Test-IsIP ($strTest) { [Net.IPAddress]::TryParse($strTest, [ref]$null) }
and
Function Get-HostName($IP) { Try { ([System.Net.DNS]::GetHostByAddress($IP)).hostName } Catch { Write-Warning "Not resolved" } }
Together these provide you with a good way of testing IP input from user and natively resolving IP addresses to DNS hostnames.