Hi @Kedar Tamboli ,
Mathematical operations are not supported in WMI, so FREESPACE/SIZE <= '0.1' can not be used.
We could use wbemtest to see if the WMI query is correct. Here is the result of this query:
So we could use powershell script to achieve it. Here is the powershell, kindly refer to it:
$DiskCount = ((Get-WmiObject -Class Win32_DiskDrive).Caption).count
$DiskInfo = Get-WmiObject -Class Win32_LogicalDisk
echo "--------------------Statistics disk partition status-------------------------"
echo " Drive letter Free space Remaining proportions"
foreach ($Drivers in $DiskInfo)
{
$PartitionID = $Drivers.DeviceID
if ($PartitionID -eq 'c:'){
$PartitionSize = "{0:N2}GB" -f ($Drivers.Size/1GB)
$PartitionFreeSize = "{0:N2}GB" -f ($Drivers.FreeSpace/1GB)
$PartitionFree = ($PartitionFreeSize/$PartitionSize)*100
if(($PartitionFree -le 10) -or ($PartitionFreeSize/1 -lt 5GB)){
echo " $PartitionID $PartitionFreeSize $PartitionFree%"
}
}
}
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.