wmic /failfast 什么都不做
wmic /failfast does nothing
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
这是我的代码,它可以正常工作,但是 /FAILFAST:ON
如果您等待 10-20 秒,它会跳到下一步,我需要它更快地扫描大型系统,任何人都知道有什么想法吗?
我可以使用 if 命令来 ping 1 个数据包,如果没有响应则转到下一个吗?
感谢 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"
)
了解 /FAILFAST
switch:
Whether or not the /NODE
computers are checked before trying to
execute the WMIC
commands against them. When FAILFAST
is ON
,
WMIC
pings the computers in the /NODE
switch before sending WMIC
commands to them. If they do not respond to the ping, the WMIC
commands are not executed for them.
每个服务器一个日志文件:
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"
)
或所有服务器的唯一日志文件:
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"
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
这是我的代码,它可以正常工作,但是 /FAILFAST:ON
如果您等待 10-20 秒,它会跳到下一步,我需要它更快地扫描大型系统,任何人都知道有什么想法吗?
我可以使用 if 命令来 ping 1 个数据包,如果没有响应则转到下一个吗?
感谢 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"
)
了解 /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.
每个服务器一个日志文件:
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"
)
或所有服务器的唯一日志文件:
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"