I made a powershell script that displays the disk size and free space in GB and percent. How to make a condition here, so that after reaching 51%, a message is displayed that there is not enough space?
$props = @(
'DriveLetter'
@{
Name = 'SizeRemaining'
Expression = { "{0:N2} GB" -f ($_.SizeRemaining/ 1Gb) }
}
@{
Name = 'Size'
Expression = { "{0:N2} GB" -f ($_.Size / 1Gb) }
}
@{
Name = '% Free'
Expression = { "{0:P}" -f ($_.SizeRemaining / $_.Size) }
}
)
Get-Volume -DriveLetter C | Select-Object $props
if ( $_.SizeRemaining -lt 50 )
{
Write-Host "warning"
}
else {
Write-Host ("ok")
}