· 8 years ago · Nov 24, 2017, 10:46 AM
1:: -----------------------------------------------------------------------------------
2:: Get System Information of Multiple Hosts
3:: -----------------------------------------------------------------------------------
4::
5:: Scans one or many hosts via wmi queries.
6:: Currenty supported datasets:
7:: wmic os get /all
8:: wmic qfe get /all
9:: wmic logicaldisk get caption,description,filessystem,size,freespace,compressed
10:: wmic process list brief
11:: wmic bios list full
12:: -----------------------------------------------------------------------------------
13
14
15@echo off
16setlocal
17set desktop=%userprofile%\desktop
18set working=%desktop%\rhosts
19set filesdir=%working%\files
20::set %host%=%1
21
22
23:: Create Working Directories
24mkdir %working%
25mkdir %filesdir%
26
27
28:: Create Document Header
29echo ^<HTML^>^<HEAD^>^<TITLE^>rhosts-info^</TITLE^>^</HEAD^> >> %working%\index.html
30echo ^<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="3b6689" VLINK="3b6689"^> >> %working%\index.html
31echo ^<h1 align="center"^>^<b^>^<font face="serif" size="+4" color=""^>WMIC System Information^</font^>^</b^>^</h1^> >> %working%\index.html
32echo ^<p align="center"^>^<table border="1" width="auto" color="666666"^> >> %working%\index.html
33
34
35:: Define Page Table Header
36echo ^<tr^>^<td^>^<B^>PC Name^</td^> >> %working%\index.html
37echo ^<td^>^<B^>OS Information^</td^> >> %working%\index.html
38echo ^<td^>^<B^>Installed KB Packages^</td^> >> %working%\index.html
39echo ^<td^>^<B^>Disk Information^</td^> >> %working%\index.html
40echo ^<td^>^<B^>Running Applications^</td^> >> %working%\index.html
41echo ^<td^>^<B^>BIOS Information^</td^>^</B^>^</tr^>^</p^> >> %working%\index.html
42
43
44:: Does rhosts.txt exist?
45if not exist rhosts.txt (
46 goto :SINGLE
47) else (
48 goto :MULTIPLE
49)
50
51
52:MULTIPLE
53:: Main Loop (rhosts.txt)
54echo The rhosts.txt file exists!
55for /F "tokens=*" %%i in (rhosts.txt) do (
56 echo Getting information on host: %%i
57 wmic /node:"%%i" /output:"%filesdir%\%%i_OS.html" os get /all /format:hform
58 wmic /node:"%%i" /output:"%filesdir%\%%i_qfe.html" qfe get /all /format:htable
59 wmic /node:"%%i" /output:"%filesdir%\%%i_drives.html" logicaldisk get caption, description, filesystem, size, freespace, compressed /format:htable
60 wmic /node:"%%i" /output:"%filesdir%\%%i_procs.html" process list brief /format:htable
61 wmic /node:"%%i" /output:"%filesdir%\%%i_bios.html" bios list full /format:htable
62 echo ^<tr^>^
63 echo ^<td^>^<b^>%%i^</b^>^</td^> >> %working%\index.html
64 echo ^<td^>^<a href="file://%filesdir%/%%i_os.html"^>Software Information^</a^>^</td^> >> %working%\index.html
65 echo ^<td^>^<a href="file://%filesdir%/%%i_qfe.html"^>Windows Updates^</a^>^</td^> >> %working%\index.html
66 echo ^<td^>^<a href="file://%filesdir%/%%i_drives.html"^>Drive Volumes^</a^>^</td^> >> %working%\index.html
67 echo ^<td^>^<a href="file://%filesdir%/%%i_procs.html"^>Process List^</a^>^</td^> >> %working%\index.html
68 echo ^<td^>^<a href="file://%filesdir%/%%i_bios.html"^>BIOS Detail^</a^>^</td^> >> %working%\index.html
69 echo ^</tr^> >> %working%\index.html
70)
71goto :DONE
72
73
74:SINGLE
75set /p host=Please enter a host to scan:
76echo Getting information on host: %host%
77wmic /node:"%host%" /output:"%filesdir%\%host%_OS.html" os get /all /format:hform
78wmic /node:"%host%" /output:"%filesdir%\%host%_qfe.html" qfe get /all /format:htable
79wmic /node:"%host%" /output:"%filesdir%\%host%_drives.html" logicaldisk get caption, description, filesystem, size, freespace, compressed /format:htable
80wmic /node:"%host%" /output:"%filesdir%\%host%_procs.html" process list brief /format:htable
81wmic /node:"%host%" /output:"%filesdir%\%host%_bios.html" bios list full /format:htable
82echo ^<tr^>^
83echo ^<td^>^<b^>%host%^</b^>^</td^> >> %working%\index.html
84echo ^<td^>^<a href="file://%filesdir%/%host%_os.html"^>Software Information^</a^>^</td^> >> %working%\index.html
85echo ^<td^>^<a href="file://%filesdir%/%host%_qfe.html"^>Windows Updates^</a^>^</td^> >> %working%\index.html
86echo ^<td^>^<a href="file://%filesdir%/%host%_drives.html"^>Drive Volumes^</a^>^</td^> >> %working%\index.html
87echo ^<td^>^<a href="file://%filesdir%/%host%_procs.html"^>Process List^</a^>^</td^> >> %working%\index.html
88echo ^<td^>^<a href="file://%filesdir%/%host%_bios.html"^>BIOS Detail^</a^>^</td^> >> %working%\index.html
89echo ^</tr^> >> %working%\index.html
90goto :DONE
91
92
93:DONE
94echo ^<p align="center"^>^<b^>^<font size="+1" color="000"^>^<BR^>Completed: >> %working%\index.html
95time /T >> %working%\index.html
96echo - on >> %working%\index.html
97date /T >> %working%\index.html
98echo ^</font^>^</b^>^<BR^>^</p^> >> %working%\index.html
99goto :END
100
101
102:USAGE
103echo USAGE: rhosts
104
105:END
106start iexplore.exe "file:///%userprofile%/Desktop/rhosts/index.html
107pause