Script to convert FQDN to IP Address

Create a file in Notepad called “LookupFQDN.cmd” and put the following contents inside:

@del Results.txt
@for /f %%I in (Hostnames.txt) do ping -n 1 %%I >> Results.txt
@find “Pinging” Results.txt > Output.txt
@del Results.txt
@for /f “eol=- tokens=2,3 delims= ” %%I in (Output.txt) do echo %%J >> Results.txt
@del Output.txt

Put the file “Hostnames.txt” in the same directory where this CMD file is located, and run the LookupFQDN script.  It should process each line in the “Hostnames.txt” file and spit out a file “Results.txt” that will contain the IP addresses for all of the entered FQDN names.

You might have to remove the brackets [] in front of and behind the IP addresses.

You may also like