Forum Discussion
Susan_Griffiths
Apr 15, 2020Copper Contributor
Need TOTAL (all disks added together) disk size for multiple servers
I can use the get-wmiobject Win32_LogicalDisk to get size by drive - But I need the total space (all drives added together) per multiple servers. What would be the best way just pull the total disk...
Susan_Griffiths
Apr 15, 2020Copper Contributor
For example, I can get this -
C drive - 100 GB
D drive - 100 GB
But I need
Servername - 200 GB
- Animesh JoshiApr 21, 2020Brass ContributorAssuming you have list of server names one per line in a .txt file
$svTbl = @{}
$servers = get-content -path c:\temp\server-names.txt
foreach($srvr in $server) {
$totalSpc = 0
$svTbl.add($srvr,$totalSpc)
get-wmiobject -class win32_logicalDisk | where-object {$_.driveType -eq 3 -and `
!($_.volumeName -eq $null)} | foreach-object {$totalSpc = $totalSpc + $_.size}
$svTbl[$srvr] = $totalSpc
}
$svTbl