How Much Diskspace Is Free On Several Servers

There are times you want a script to find out how much space is available on a list of servers. I was looking for this scripts and with most of the scripts here this one is also from Microsoft site named the scripting guys

You want this list to be changed whenever it suits you so here is the script and explanation:

@echo off 

for /f %%S IN (serverPClist.txt) DO ( 
echo Checking drives on Server %%S... 
for /D %%D IN (C D E F G H I J K L M N O P Q R S T V W X Y Z) DO ( 

psexec \\%%S cmd /c if exist %%D:\* dir %%D:\ | findstr /c:"bytes" > %temp%\%%S-%%D.txt 
) 
) 

color 0D 

for /f %%S IN (serverPClist.txt) DO ( 
echo. & echo. 
echo ********** Displaying output for server %%S... ********** 

for /D %%D IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO ( 
for /f "tokens=1,2,3,4" %%F IN ('if exist %temp%\%%S-%%D.txt type %temp%\%%S-%%D.txt') DO ( 
if /i "%%G" == "Dir(s)" echo For the %%D: drive: %%H bytes free space. 
if /i "%%G" == "bytes" echo For the %%D: drive: %%F bytes free space. 
echo. 
) 
) 
echo Done!
)

You will need a textfile named serverPClist.txt where you only put in the name of the servers 1 at 1 line.

Ofcourse you need admin rights on the server

The output looks something like:

Displaying output for server XXXXX… **

For the C: drive: 1,979,961,344 bytes free space.

For the D: drive: 5,371,101,184 bytes free space.

For the E: drive: 20,127,297,536 bytes free space.

For the F: drive: 351,453,184 bytes free space.

For the G: drive: 10,888,171,520 bytes free space.

For the H: drive: 6,241,230,848 bytes free space.

For the I: drive: 52,615,041,024 bytes free space.

For the J: drive: 20,502,626,304 bytes free space.

For the K: drive: 69,176,549,376 bytes free space.

For the L: drive: 78,559,260,672 bytes free space.

For the M: drive: 69,452,783,616 bytes free space.

For the N: drive: 71,110,791,168 bytes free space.

Done!

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License