# To monitor disk space usage
$volumeSet = Get-WmiObcject -Class win32_volume -ComputerName localhost -filter "drivetype = 3"
foreach($volume in $volumeSet)
{
$drive = $volume.DriveLetter
if ($drive -eq "d:")
{
[int]$free = $volume.FreeSpace/1GB
[int]$capacity = $volume.Capacity/1GB
Write-Host -ForegroundColor blue "Free space on $drive = $free 't't Total Capacity on $drive = $capacity"
if ($free -lt 10)
{
Write-Host -ForegroundColor red "Remove the top 5 old build folder to release space."
$LocalBuildFolder01 = "D:\Build\9.1\main\"
Get-ChildItem $LocalBuildFolder01 | Sort-Object |select-Object -first 5 | Remove-Item -Recurse -Force
}
}
}