Disk information using powershell

One of the things DBA’s need to make sure is that database server disks do not run out of space. So, the disk free space should be monitored, however, if you manage multiple servers, it is not always convenient to log into every server. The below powershell code will return the disk information including available free space.

$ServerList ="ServerA","ServerB"
foreach ($Server in $ServerList)
{
#Eliminates System Volume and DriveType=5 (Media Drive).
get-wmiobject "win32_volume" -computerName $Server | Where-Object {$_.SystemVolume -like "False" -and $_.DriveType -ne 5}|
Select-Object SystemName,Name,Label,Capacity,FreeSpace,BlockSize|Format-Table -AutoSize
}

Advertisement