Batch Script: Query Disk Space Across Multiple Servers using PsInfo

Managing disk space across a sprawling server environment is a constant challenge. While modern monitoring tools exist, sometimes you just need a quick, lightweight way to pull drive statistics from a specific list of servers without setting up complex infrastructure.
This “Lazy Admin” solution uses the classic PsInfo utility from the Microsoft Sysinternals suite to sweep your network and compile disk data into a single CSV.
Prerequisites
Before running the script, ensure you have the following in a single folder:
- PsInfo.exe: Download this as part of the PSTools suite from Microsoft.
- Servers.txt: A simple text file containing the names or IP addresses of your target servers (one per line).
- Admin Rights: You must execute the script with a domain account that has local administrative privileges on the remote servers.
The DiskSpace.cmd Script
Copy the code below and save it as DiskSpace.cmd in your PSTools folder.
@Echo OffSetLocal EnableDelayedExpansion:: Delete existing report if it existsIF EXIST Free_Disk_Space_Servers.csv DEL Free_Disk_Space_Servers.csv:: Loop through the Servers.txt fileFOR /F "Tokens=*" %%L IN (Servers.txt) DO ( SET ServerName=%%L Echo Processing !ServerName!... :: Run PsInfo against the remote server and append output to CSV :: The -d switch pulls disk volume information Psinfo -d /accepteula \\!ServerName! >> Free_Disk_Space_Servers.csv)Echo Export Complete: Free_Disk_Space_Servers.csvPause
How it Works
Psinfo -d: The-dflag tells the utility to display volume information, including drive letters, total size, and free space.SetLocal EnableDelayedExpansion: This allows the script to update theServerNamevariable dynamically as it loops through your text file.>> Free_Disk_Space_Servers.csv: This appends the output of every server query into one continuous file./accepteula: Added to the command to ensure the script doesn’t hang waiting for you to click “Accept” on the Sysinternals license agreement for every server.
💡 Lazy Admin Tip
The output from PsInfo is a bit “chatty” for a standard CSV. Once you open it in Excel, use the Data > Text to Columns feature or simple Find/Replace to clean up the headers. If you need a more modern, native approach, consider using a PowerShell one-liner like: Get-WmiObject Win32_LogicalDisk -ComputerName (Get-Content Servers.txt) | Select-Object SystemName, DeviceID, FreeSpace
#SysAdmin #WindowsServer #Sysinternals #PSTools #BatchScript #ITPro #DiskManagement #LazyAdmin #ServerAudit #TechTips