I am working to create a script that you can type in a computer name on the network and it will give you the IP Address. Also if you enter the IP Address it will give you the computer name. There are several commands that will do this such as NSLOOKUP and NBTSTAT but they list a bunch more data than just the IPAddress/computer name .
ex.
set /p compname=Enter Computer Name:
NBTSTAT -a %compname%| Find "IpAddress:"
echo %compname%
This displays:"Node IpAddress: [10.17.194.59] Scope Id: []"
I am looking for a way so just the computer name/IP Address get listed at the end without all of the other data.
Script to get computer name based on IP Address
Moderator: DosItHelp
Re: Script to get computer name based on IP Address
Use FOR /F to process the output.
Regards
aGerman
Code: Select all
for /f "tokens=2 delims=[]" %%a in ('nbtstat -a %compname%^|find "IpAddress:"') do echo %compname%/%%a
Regards
aGerman