How can I find out how much disk space is available/used/free remote Windows servers using a .bat command?
Asked
Active
Viewed 2,450 times
4
terdon
- 53,403
user211958
- 41
-
1.bat is old, try Powershell. – Tamara Wijsman Mar 27 '13 at 19:34
1 Answers
2
If you are anywhere in the domain there is powershell, then the following command to save the output in a shared folder:
powershell gwmi Win32_LogicalDisk -Filter "DriveType=3" ^| select Name, FileSystem,FreeSpace,BlockSize,Size ^| % {$_.BlockSize=(($_.FreeSpace)/($_.Size))*100;$_.FreeSpace=($_.FreeSpace/1GB);$_.Size=($_.Size/1GB);$_} ^| ft -property @{n='Name';e={$_.Name}},FileSystem,@{n='Free,Gb';e={'{0:N2}' -f $_.FreeSpace}}, @{n='Free,%';e={'{0:N2}' -f $_.BlockSize}},@{n='Size,Gb';e={'{0:N3}' -f $_.Size}} -AutoSize
way 2:
wmic logicaldisk where DriveType="3" get caption, VolumeName, VolumeSerialNumber, Size, FileSystem, FreeSpace
You can create a lot of requests for WMI remote machines using the list, for example:
wmic /node::@"c:\computers.txt" <<WQL query>>
List of computers in the domain:
dsquery computer -limit 5000 | dsget computer -samid
If you want to make sure the work on all windows operating systems use WSH scripts.
Additional:
Free space, files and a directory for a particular disk:
dir C:\ /A:- | find " bytes" | findstr [0-9]*\s*i*(s)
enumeration drive names:
mountvol | findstr .:\\
May be names which removed in system - "extra" disk names -
REG QUERY "HKLM\SYSTEM\MountedDevices" /v /k /f "\DosDevices\*:"
STTR
- 6,775