for /f "tokens=*" %%a in (ip.txt) do (
wmic /FAILFAST:ON /node:%%a /user: /password: computersystem get Name, domain, Manufacturer, Model, NumberofProcessors, PrimaryOwnerName,Username, Roles, totalphysicalmemory /format:list
wmic /FAILFAST:ON /node:%%a /user: /password: cpu get Name, Caption, MaxClockSpeed, DeviceID, status /format:list
wmic /FAILFAST:ON /node:%%a /user: /password: path Win32_VideoController get Name, status, DeviceID /format:list
wmic /FAILFAST:ON /node:%%a /user: /password: os get Version, Caption, CountryCode, CSName, Description, InstallDate, SerialNumber, ServicePackMajorVersion, WindowsDirectory /format:list
wmic /FAILFAST:ON /node:%%a /user: /password: csproduct get identifyingnumber /format:list
) >%%a.txt
This is my code and it works like it should do, but the /FAILFAST:ON
it does skip to next if you wait 10-20 sec, I need it to go faster to scan large systems, anybody got any ideas?
Could I use an if command that pings with 1 packet and goes to next if no response ?
thanks to JosefZ:
for /f "tokens=*" %%a in (ip.txt) do (
set "_ready="
for /F %%G in ('ping -4 -n 1 %%a^|find "TTL="') do set "_ready=%%G"
if defined _ready (
rem your `WMIC /FAILFAST:OFF /node:%%a …`
wmic /node:%%a /user: /password: computersystem get Name, domain, Manufacturer, Model, NumberofProcessors, PrimaryOwnerName,Username, Roles, totalphysicalmemory /format:list
wmic /node:%%a /user: /password: cpu get Name, Caption, MaxClockSpeed, DeviceID, status /format:list
wmic /node:%%a /user: /password: path Win32_VideoController get Name, status, DeviceID /format:list
wmic /node:%%a /user: /password: os get Version, Caption, CountryCode, CSName, Description, InstallDate, SerialNumber, ServicePackMajorVersion, WindowsDirectory /format:list
wmic /node:%%a /user: /password: csproduct get identifyingnumber /format:list
)>"%%a.txt"
)
Read about /FAILFAST
switch:
Whether or not the
/NODE
computers are checked before trying to execute theWMIC
commands against them. WhenFAILFAST
isON
,WMIC
pings the computers in the/NODE
switch before sendingWMIC
commands to them. If they do not respond to the ping, theWMIC
commands are not executed for them.
One log file for each server:
for /f "tokens=*" %%a in (ip.txt) do (
set "_ready="
for /F %%G in ('ping -4 -n 1 %%a^|find "TTL="') do set "_ready=%%G"
if defined _ready (
rem your `WMIC /FAILFAST:OFF /node:%%a …` commands here
)>"%%a.txt"
)
or the only log file for all servers:
for /f "tokens=*" %%a in (ip.txt) do (
set "_ready="
for /F %%G in ('ping -4 -n 1 %%a^|find "TTL="') do set "_ready=%%G"
if defined _ready (
rem your `WMIC /FAILFAST:OFF /node:%%a …` commands here
)
)>"logservers.txt"