wmic/failfast什么都不做 [英] wmic /failfast does nothing

查看:62
本文介绍了wmic/failfast什么都不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    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

这是我的代码,它的工作原理与它应该做的一样,但是如果等待10到20秒,它会跳到下一个/FAILFAST:ON ,我需要它更快地进行大尺寸扫描系统,有人有想法吗?

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?

我可以使用if命令对1个数据包执行ping操作,如果无响应则转到下一个命令吗?

Could I use an if command that pings with 1 packet and goes to next if no response ?

感谢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:

是否在尝试检查/NODE 计算机之前对它们执行 WMIC 命令.当 FAILFAST 设置为 ON 时,在发送 WMIC 之前, WMIC /NODE 开关中对计算机执行ping操作.命令给他们.如果他们不响应ping,则 WMIC 不会为其执行命令.

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.

每个服务器一个日志文件:

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"

这篇关于wmic/failfast什么都不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆