Update check-drive-space.ps1

This commit is contained in:
Markus Fleschutz 2021-03-02 15:30:13 +01:00 committed by GitHub
parent 41c83f9ec0
commit ffd527dbe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,9 +13,8 @@ if ($Drive -eq "" ) {
} }
try { try {
$FreeSpace = (get-psdrive $Drive).free $FreeSpace = (get-psdrive $Drive)
if ($lastExitCode -ne "0") { throw "'get-psdrive $Drive' failed" } [int]$FreeSpace = (($FreeSpace.free / 1024) / 1024) / 1024
[int]$FreeSpace = (($FreeSpace / 1024) / 1024) / 1024
if ($FreeSpace -lt $WarningLevel) { if ($FreeSpace -lt $WarningLevel) {
write-warning "Drive $Drive has only $FreeSpace GB free space left! (warning level is < $WarningLevel GB)" write-warning "Drive $Drive has only $FreeSpace GB free space left! (warning level is < $WarningLevel GB)"