"I need an up-to-date list of disk space usage for all servers, on my desk in 5 minutes"

July 20, 2009

Sounds familiar?

With (native) Windows XP Professional or Windows Server 2003 commands:

    FOR /F %%A IN (servers.txt) DO (
WMIC /Node:%%A LogicalDisk Where DriveType="3" Get DeviceID,FileSystem,FreeSpace,Size /Format:csv | MORE /E +2 >> SRVSPACE.CSV
)

The only prerequisites are:

  1. SRVSPACE.CSV should not exist or be empty,
  2. a list of server names in a file named SERVERS.TXT, one server name on each line,
  3. and WMIC.EXE, which is native in Windows XP Professional, Windows Server 2003 and Vista.

The CSV file format is ServerName,DeviceID,FileSystem,FreeSpace,Size (one line for each harddisk partition on each server).

If you have a strict server naming convention, SERVERS.TXT itself can be generated with the NET command:

    FOR /F "delims=\  " %%A IN ('NET VIEW ^| FINDSTR /R /B /C:"\\\\SRV\-"') DO (>>SERVERS.TXT ECHO.%%A)
Notes: (1) assuming server names start with "SRV-"; modify to match your own naming convention.
(2) delims is a backslash, followed by a tab and a space.

Related Posts

  • How do I reset someone's password?With the native NET command: NET USER loginname newpassword /DOMAIN With (native) Windows Server 2003 commands: ...
  • Setup the vSphere Management AssistantSetup the vSphere Management AssistantThe below article describes the initial stpes in setting up a vSpehre Management ...
  • Useful VMware CommandsUseful VMware CommandsRestart management services:Service mgmt-vmware restartFind DNS servers:Cat /etc/resolv.confCheck ...
  • Many users are asking how to remove evaluation copy (Or testing purpose only) watermark that appears on the bottom ...
  • Retaining Individual E-mail MessagesBest Practice Definition Retaining unnecessary messages quickly takes up the storage space on the Exchange server. This ...

No comments