Script to check disk space on multiple servers
- Download PSTool.
- Create script.
- Create Hostlist.txt
- Download PsInfo.exe and PsInfo64.exe from below Microsoft link.
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:
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.