Add dns lookups to this script

Hello I’m very new to powershell and was given this script, I’ll post credit here after he says it’s okay if I share who he is.

I’d like to see if it’s possible to add DNS lookups to resolve hostnames in this.

#Ping Sweep
function New-IPRange ($start, $end) {
$ip1 = ([System.Net.IPAddress]$start).GetAddressBytes()
$ip1 = ([System.Net.IPAddress]($ip1 -join ‘.’)).Address

$ip2 = ([System.Net.IPAddress]$end).GetAddressBytes()
$ip2 = ([System.Net.IPAddress]($ip2 -join ‘.’)).Address

for ($x=$ip1; $x -le $ip2; $x++) {
$ip = ([System.Net.IPAddress]$x).GetAddressBytes()
$ip -join ‘.’
$ping = New-Object System.Net.NetworkInformation.Ping
New-IPRange | ForEach-Object {$ping.Send($, 100)} | where {$.status -eq “Success”}

Yes, that is possible. The System.Net.Dns class have a method called GetHostEntry that you can use. You can read more about System.Net.Dns at