To create a batch file that can gather information on all network assets, you can use a combination of commands and tools that are built into Windows. Here's an example batch file that can retrieve information such as IP addresses, hostnames, and MAC addresses for all devices on the network:
Save the file as on batch file name .
-----------------------------------------------------------------------------------------------------------------------------
Copy code
@echo off
echo Gathering network asset information...
echo.
for /f "tokens=1-2 delims=:" %%a in ('ipconfig /all^|findstr "Physical Address"') do (
set mac=%%b
for /f "tokens=*" %%c in ('ping -a -n 1 %%a ^| findstr /c:"Pinging"') do (
set ip=%%a
set host=%%c
set host=!host:~13!
echo Hostname: !host!
echo IP address: !ip!
echo MAC address: !mac:~1!
echo.
)
)
pause
----------------------------------------------------------------------------------------------------------------------------
Save this as a .bat file and run it. The batch file will use the "ipconfig" command to retrieve the MAC addresses of all network interfaces, and then use the "ping" command to resolve the IP addresses and hostnames of the devices. The output will be displayed in the command prompt window.
Note that this batch file may take some time to complete, especially on large networks, and may not be able to retrieve information on all devices. Additionally, some devices may be configured to block ping requests or other network traffic, which can prevent the script from retrieving their information.
Comments
Post a Comment