To get the list of hostnames of a
network, first create a txt file with includes one ip address in each
line (ip_list.txt). You can get the hostname list (hostname_list.txt) of
the IP addresses that you wrote in the ip_list.txt file with using the
script below;
($_)).hostname >> "C:\hostname_list.txt"
}
If you also want to see the IP addresses that cannot be resolved, you can use the script below;
get-content C:\ip_list.txt | foreach-object{$a=([system.net.Dns]::GetHostByAddress
($_)).hostname
if($? -eq $False) {
add-content C:\hostname_list.txt $_, "Cannot resolve hostname"," "
}
elseif($? -eq $True){
add-content C:\hostname_list.txt $_,$a," "
}}
We made a tiny application and published it in sourceforge for resolving hostnames from an IP Address list, and for the opposite of it. Hope you like it.
http://secureeo.blogspot.com.tr/p/ip-hostname-converter.html
No comments:
Post a Comment