Hi stack overflow collegues,
Im building a script but i can get it to complete cause im struggling getting the if statement working.
$freespace = [math]::round((Get-WmiObject Win32_Volume -Filter "Label='User Disk'" | Foreach-Object {$_.FreeSpace})/ 1MB)
$volumespace = [math]::round((Get-WmiObject Win32_Volume -Filter "Label='User Disk'" | Foreach-Object {$_.Capacity})/ 1MB)
$usedspace=$volumespace-$freespace
Write-Host
"Used Space: $usedspace"
"Free Space: $freespace"
"Total Space Assigned: $volumespace"
The if statement needs to calculate like this: if $freespace is less then 80% of the $volumespace..
then my send mail command get attached to it. What options do i have, only to get this working if spend 3 hours and i dont know how to make this calculation, can anyone raise a hand for me?
Thank for helping!
Aucun commentaire:
Enregistrer un commentaire