Skip to main content

How to Create a System Information Summary Report in Batch Script

When troubleshooting a remote computer or preparing for a hardware upgrade, you need a snapshot of the machine's vital signs. Manually hunting for the CPU model, RAM capacity, OS build, and disk status takes too long. A Batch script can gather all this critical metadata into a single, structured summary report. This document can then be emailed to support, saved to a server share, or kept locally as an audit trail.

This guide will explain how to aggregate system data into a professional summary report.

This method uses PowerShell to query system information reliably, with proper 64-bit arithmetic for memory calculations and locale-independent output. The Batch script orchestrates the collection and builds a formatted text report.

@echo off
setlocal EnableDelayedExpansion

set "Report=%~dp0SystemSummary_%COMPUTERNAME%.txt"

echo [INFO] Generating system report... Please wait.

:: =============================================
:: Header
:: =============================================
(
echo ==================================================
echo SYSTEM INFORMATION SUMMARY REPORT
echo ==================================================
) > "%Report%"

:: Timestamp via PowerShell for locale-independent format
for /f "delims=" %%t in (
'powershell -NoProfile -Command "Get-Date -Format 'yyyy-MM-dd HH:mm:ss'"'
) do echo Generated: %%t >> "%Report%"

echo Computer Name: %COMPUTERNAME% >> "%Report%"
echo Current User: %USERNAME% >> "%Report%"
echo. >> "%Report%"

:: =============================================
:: OS Details
:: =============================================
echo --- Operating System --- >> "%Report%"

for /f "delims=" %%a in (
'powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).Caption"'
) do echo OS Name: %%a >> "%Report%"

for /f "tokens=1,2" %%a in (
'powershell -NoProfile -Command "$os = Get-CimInstance Win32_OperatingSystem; $os.Version + [char]32 + $os.BuildNumber"'
) do echo OS Version: %%a Build %%b >> "%Report%"

for /f "delims=" %%a in (
'powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).OSArchitecture"'
) do echo Architecture: %%a >> "%Report%"

echo. >> "%Report%"

:: =============================================
:: Hardware
:: =============================================
echo --- Hardware --- >> "%Report%"

for /f "delims=" %%a in (
'powershell -NoProfile -Command "(Get-CimInstance Win32_Processor).Name"'
) do echo CPU: %%a >> "%Report%"

for /f "delims=" %%a in (
'powershell -NoProfile -Command "[math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1GB, 1)"'
) do echo Total RAM: %%a GB >> "%Report%"

for /f "delims=" %%a in (
'powershell -NoProfile -Command "(Get-CimInstance Win32_ComputerSystem).Model"'
) do echo System Model: %%a >> "%Report%"

for /f "delims=" %%a in (
'powershell -NoProfile -Command "(Get-CimInstance Win32_BIOS).SerialNumber"'
) do echo Serial Number: %%a >> "%Report%"

echo. >> "%Report%"

:: =============================================
:: Network
:: =============================================
echo --- Network --- >> "%Report%"

for /f "delims=" %%a in (
'powershell -NoProfile -Command "Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object IPEnabled | ForEach-Object { $_.Description + ([char]58) + ([char]32) + ($_.IPAddress -join ([char]44 + [char]32)) }"'
) do echo %%a >> "%Report%"

echo. >> "%Report%"

:: =============================================
:: Disk Status
:: =============================================
echo --- Disk Space --- >> "%Report%"

for /f "tokens=1-3" %%a in (
'powershell -NoProfile -Command "Get-CimInstance Win32_LogicalDisk | Where-Object DriveType -eq 3 | ForEach-Object { $t = [math]::Round($_.Size / 1GB, 1); $f = [math]::Round($_.FreeSpace / 1GB, 1); $_.DeviceID + [char]32 + [string]$t + [char]32 + [string]$f }"'
) do (
echo Drive %%a Total: %%b GB Free: %%c GB >> "%Report%"
)

echo. >> "%Report%"

:: =============================================
:: Footer
:: =============================================
echo ================================================== >> "%Report%"

echo [OK] Report saved to: %Report%

endlocal
exit /b 0

Sample output:โ€‹

==================================================
SYSTEM INFORMATION SUMMARY REPORT
==================================================
Generated: 2024-05-10 14:32:05
Computer Name: WORKSTATION-07
Current User: jsmith

--- Operating System ---
OS Name: Microsoft Windows 11 Pro
OS Version: 10.0.22631 Build 22631
Architecture: 64-bit

--- Hardware ---
CPU: Intel(R) Core(TM) i7-12700K CPU @ 3.60GHz
Total RAM: 32.0 GB
System Model: OptiPlex 7090
Serial Number: ABC1234XYZ

--- Network ---
Intel(R) Ethernet Controller: 192.168.1.50, fe80::1a2b:3c4d:5e6f:7890

--- Disk Space ---
Drive C: Total: 476.9 GB Free: 234.1 GB
Drive D: Total: 931.5 GB Free: 612.3 GB

==================================================

Why PowerShell instead of wmic:โ€‹

  • wmic.exe is deprecated since Windows 10 21H1 and may be removed in future releases.
  • wmic output contains invisible trailing \r characters that corrupt variables when captured by for /f, causing formatting issues and comparison failures.
  • PowerShell handles 64-bit arithmetic natively, so RAM conversion from bytes to GB is accurate for any amount of memory. The original Batch approach of truncating digits (%ram:~0,-9%) is imprecise, it rounds down by truncation rather than dividing, producing incorrect values for amounts that are not exact powers of 10.
  • Get-CimInstance returns clean typed data that does not require text cleanup.

Method 2: Quick Summary Using systeminfoโ€‹

Windows includes the systeminfo command, which provides a comprehensive raw dump of system information. This is the fastest approach when you need a complete report without custom formatting.

Full dump:โ€‹

@echo off
setlocal

set "Report=%~dp0full_audit_%COMPUTERNAME%.txt"

echo [INFO] Running system audit (this may take 10-30 seconds^)...

systeminfo > "%Report%" 2>&1

if errorlevel 1 (
echo [ERROR] systeminfo failed. Some data may require administrator privileges. >&2
endlocal
exit /b 1
)

echo [OK] Full audit saved to: %Report%

endlocal
exit /b 0

Filtered view (specific fields only):โ€‹

@echo off
setlocal

echo [INFO] Quick system summary:
echo.

systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Boot Time" /C:"Total Physical Memory" /C:"Available Physical Memory" /C:"System Manufacturer" /C:"System Model"

endlocal
exit /b 0

Trade-offs:โ€‹

AspectsysteminfoPowerShell (Method 1)
Speed10โ€“30 seconds (audits everything)3โ€“8 seconds (queries only what's needed)
FormattingFixed format, difficult to customizeFully customizable
LocalizationField names change by OS languageWMI property names are language-independent
Memory/disk mathPre-formatted strings, hard to parseRaw numbers, easy to calculate

Use systeminfo for quick one-off audits. Use Method 1 for scripts that will be deployed across multiple machines or need consistent parsing.

Method 3: Generating a CSV Line for Fleet Auditingโ€‹

When auditing dozens or hundreds of machines, you need one line per machine in a shared CSV file, not individual text reports.

@echo off
setlocal

set "CSVFile=\\Server\Audit\fleet_inventory.csv"

:: Write header if the file does not exist yet
if not exist "%CSVFile%" (
echo "ComputerName","OS","CPU","RAM_GB","Model","SerialNumber","IP" > "%CSVFile%"
)

echo [INFO] Collecting system data for CSV export...

:: Gather all fields in one PowerShell call for efficiency
for /f "tokens=1-6 delims=|" %%a in (
'powershell -NoProfile -Command "$os = Get-CimInstance Win32_OperatingSystem; $cs = Get-CimInstance Win32_ComputerSystem; $cpu = Get-CimInstance Win32_Processor; $bios = Get-CimInstance Win32_BIOS; $net = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object IPEnabled | Select-Object -First 1; $ram = [math]::Round($cs.TotalPhysicalMemory / 1GB, 1); $d = [char]124; $os.Caption + $d + $cpu.Name + $d + [string]$ram + $d + $cs.Model + $d + $bios.SerialNumber + $d + $net.IPAddress[0]"'
) do (
echo "%COMPUTERNAME%","%%a","%%b","%%c","%%d","%%e","%%f" >> "%CSVFile%"
)

if errorlevel 1 (
echo [ERROR] Failed to collect system data. >&2
endlocal
exit /b 1
)

echo [OK] Data appended to: %CSVFile%

endlocal
exit /b 0

Why a single PowerShell call:โ€‹

Each powershell -Command invocation takes 1โ€“3 seconds for process startup. Method 1 makes multiple calls for readability, which is fine for a single-machine report. For fleet auditing (where this script runs on every machine), combining all queries into a single PowerShell call minimizes execution time and network load.

Deployment:โ€‹

Run this script on each machine via Group Policy logon script, SCCM, PDQ Deploy, or a similar tool. Each machine appends one line to the shared CSV, building a complete fleet inventory automatically.

How to Avoid Common Errorsโ€‹

Wrong Way: Using Batch Math for RAM Conversionโ€‹

:: BROKEN: digit truncation is imprecise and locale-dependent
set "ram=17179869184"
echo RAM: %ram:~0,-9% GB

This produces 17 GB for a value that is actually 16.0 GB (17,179,869,184 bytes รท 1,073,741,824 = 16.0). The truncation approach drops the last 9 digits instead of dividing by 1 GB, which is mathematically incorrect, it divides by 1,000,000,000 instead of 1,073,741,824.

Correct Way: Use PowerShell's [math]::Round($bytes / 1GB, 1) for accurate conversion.

Wrong Way: Hardcoding User Pathsโ€‹

Saving the report to C:\Users\Admin\Desktop fails on any machine without an "Admin" account.

Correct Way: Use %~dp0 (the script's own directory) for the output path.

Problem: Slow Executionโ€‹

systeminfo takes 10โ€“30 seconds because it audits everything including installed hotfixes, which requires querying Windows Update history.

Solution: If you only need specific fields, use targeted Get-CimInstance queries (Method 1) rather than systeminfo.

Problem: Missing Data Without Admin Rightsโ€‹

Some WMI classes (BIOS serial number, certain network configurations, disk health details) return incomplete data when queried by a standard user.

Solution: Note in your report header whether the script ran with admin privileges. For fleet auditing, deploy the script via a mechanism that runs it with elevated rights.

Best Practices and Rulesโ€‹

1. Use Locale-Independent Formattingโ€‹

Avoid %date% and %time% for timestamps, their format varies by regional settings. Use PowerShell's Get-Date -Format for consistent ISO 8601 timestamps that sort correctly and parse unambiguously.

2. One Line Per Machine for Fleet Auditingโ€‹

If you are auditing multiple machines, generate CSV (Method 3) instead of individual text files. A single CSV file with one row per machine is vastly easier to analyze, sort, and import into databases or spreadsheets.

3. Protect Sensitive Dataโ€‹

System reports may contain serial numbers, IP addresses, and usernames. If the report will be shared outside your secure network, redact or omit sensitive fields. Never include passwords or security keys in any report.

4. Include Admin Status in the Reportโ€‹

Some data is only available with elevated privileges. Include a line indicating whether the script ran as administrator, so the reader knows if missing fields are due to access restrictions or actual missing data.

Conclusionsโ€‹

Creating a system information summary report is a high-impact task for any system administrator. By using PowerShell for reliable data collection and accurate arithmetic, you replace manual research with automated accuracy. Whether generating detailed single-machine reports or fleet-wide CSV inventories, this practice reduces troubleshooting time and provides a consistent, professional record of your machines' states throughout their lifecycle.