需要基本批处理文件脚本以进行服务器上的运行状况检

时间:2015-06-25 10:47:37

标签: batch-file

我正在寻找一个简单的批处理文件,它可以为我提供服务器列表的以下详细信息。有一个域名。

  • 主机名
  • IP地址
  • Disk DetailOUs
  • CPU信息
  • 物理内存
  • 操作系统详细信息
  • 服务器类型

我自己制作了一个,但它似乎没有运行服务器列表,它只运行一次服务器。请帮帮我,下面是代码:

for /f %%x in (computers.txt) do systeminfo | findstr /c:"Host Name" >> C:\temp\output.txt
for /f %%x in (computers.txt) do wmic cpu get name >> C:\temp\output.txt
for /f %%x in (computers.txt) do systeminfo | findstr /c:"Domain" >> C:\temp\output.txt
for /f %%x in (computers.txt) do systeminfo | findstr /c:"OS Name" >> C:\temp\output.txt
for /f %%x in (computers.txt) do systeminfo | findstr /c:"OS Version" >> C:\temp\output.txt
for /f %%x in (computers.txt) do systeminfo | findstr /c:"System Manufacturer" >> C:\temp\output.txt
for /f %%x in (computers.txt) do systeminfo | findstr /c:"System Model" >> C:\temp\output.txt
for /f %%x in (computers.txt) do systeminfo | findstr /c:"System type" >> C:\temp\output.txt
for /f %%x in (computers.txt) do systeminfo | findstr /c:"Total Physical Memory" >> C:\temp\output.txt
for /f %%x in (computers.txt) do ipconfig | findstr IPv4 >> C:\temp\output.txt
for /f %%x in (computers.txt) do wmic diskdrive get size >> C:\temp\output.txt
for /f %%x in (computers.txt) do dsquery computer -name %%x >> C:\temp\output.txt

1 个答案:

答案 0 :(得分:0)

如果我假设您在computers.txt中获得了服务器名称列表。

  1. 服务器名称传递给system info命令的位置在哪里?
  2. 代码中使用的
  3. for循环遍历computers.txt中的所有行,并提供机器的系统信息输出,以便在每次迭代时执行它。
  4. 3.此过程一直持续到所有行都在computers.txt迭代。

    1. 使用以下选项通过使用代码中的命令
    2. 从服务器获取系统信息

      systeminfo /s /U <<username>> /P <<password %%x use system info /? for more details

      %% x - 将包含文件的信息,并且每次迭代都会更改,它将在文件中包含相应的行值。

相关问题