Script to check disk space on multiple servers

0
97

Script to check disk space on multiple servers

  • Download PSTool.
  • Create script.
  • Create Hostlist.txt
  1. Download PsInfo.exe and PsInfo64.exe from below Microsoft link.

https://docs.microsoft.com/en-us/sysinternals/downloads/pstools

2. Copy the following commands and save with file named “free_space.cmd”.

REM ***START HERE***
Echo Off
SetLocal EnableDelayedExpansion
IF EXIST Free_Disk_Space_Servers.csv DEL Free_Disk_Space_Servers.csv
FOR /F "Tokens=*" %%L IN (Hostlist.txt) DO (
SET ServerName=
SET ServerName=%%L
Psinfo -d \ \\!ServerName!>> Free_Disk_Space_Servers.csv
)
REM ***END HERE***

3. Create another text file and save like “Hostlist.txt”. Open the text file and order all the IP servers that you need to get info:

server1
server2
server3

4. Now you can execute the script “free_space.cmd” file and the script will create a csv file where will write all the space info from the servers.

How to check disk space in windows from command line

Note! Please be sure that your Account has Admin rights on the servers where you are trying to check hard drive space info.

SHARE
Previous articlePassword Generator
Next articleScript to delete files older than 7 days
mm
Hi, I’m Ravinder Jaiswal. I’m the person behind this website. Thank you for visiting the website! My website is all about Microsoft, VMware, Red Hat, Citrix and other technologies. I have 14+ years of IT experience. I am AZURE, MCSA 2016, MCSE 2016, RHCSA 7, RHCE 7, VCP-DCV 6.5, VCP-DTM 6.1, ITILv3 certified.