I have faced many sitiation in my IT career where I have to get host names from alist of IP address & sometime ipaddress to hostnames. I have researched on internet & found two useful scripts but never got a time to share it on my blog. Today I got the same situation & I used those scripts to accomplish my task.
Below are the two scripts:-
1. Hostname to Ip address( it will take input from text file & resturn in CSV)
Echo Computername,IP Address>Final.csv
for /f “usebackq tokens=*” %%A in (“%ComputerList%”) do (
for /f “tokens=3” %%B in (‘ping -n 1 -l 1 %%A ^|findstr Reply’) do (
2. IP address to hostnames( it will take input from text file & resturn in txt file)
for /F %%a in (‘type c:\hostname\ip.txt’) do call :Sub %%a
for /F %%b in (‘nbtstat -A %1 ^| find “<00>” ^| find /i “unique”‘) do echo %1 Hostname %%b
Thanks to the scripters that created these scripts.
One thought on “IP to HostName and HostName to IP to text file script”
This tiny tool also can help;