You know, to make this REALLLLLY useful, I added /node:%1
(to get IP of remote computer)
Saves some legwork for system admins & network admins vs. ping or nslookup.
I'm sure the other thing I will add is 'error-checking' so that, IF the system happens to not be available, the script can "log that info" - like System %1 not available
- and then move on to grab the ip of the next system.
Often, I make a 'bat' to 'call a bat'
So, I would just create a batch file maybe like "getall.bat" below:
Then just run it like this: getall > getall-log.txt 2>&1
(Above will pipe out all the info to a text file, including any errors encountered)
getall.bat
rem getall.bat
call getnic.bat workstation1
call getnic.bat workstation2
call getnic.bat server1
call getnic.bat server2
rem end of getall.bat
getnic.bat
rem - getnic.bat
@echo off
setlocal
set varcounter=0
set wmicmd="wmic /node:%1 NICCONFIG WHERE IPEnabled=true GET IPAddress"
for /f "tokens=1 delims={, skip=1" %%a in ('%wmicmd%') do call :SETVAR %%a
endlocal
goto :eof
:SETVAR
set /a varcounter=%varcounter% + 1
if not {%1}=={} (
echo NIC %varcounter% address is {%1}
set NIC%varcounter%=%1
)
goto :eof
rem end of getnic.bat