mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-27 17:19:16 +01:00
Improved check-drive-space.ps1
This commit is contained in:
parent
2ef09c2390
commit
ca5ba276d9
@ -13,16 +13,16 @@ if ($Drive -eq "" ) {
|
||||
}
|
||||
|
||||
try {
|
||||
$FreeSpace = (get-psdrive $Drive).free
|
||||
[int]$FreeSpace = (($FreeSpace / 1024) / 1024) / 1024
|
||||
$FreeSpace = (get-psdrive $Drive).free
|
||||
if ($lastExitCode -ne "0") { throw "'get-psdrive $Drive' failed" }
|
||||
[int]$FreeSpace = (($FreeSpace / 1024) / 1024) / 1024
|
||||
|
||||
if ($FreeSpace -lt $WarningLevel) {
|
||||
write-warning "Drive $Drive has only $FreeSpace GB free space left! (warning level is < $WarningLevel GB)"
|
||||
exit 1
|
||||
} else {
|
||||
write-host -foregroundColor green "OK - drive $Drive has $FreeSpace GB free space left (warning level is < $WarningLevel GB)"
|
||||
exit 0
|
||||
}
|
||||
if ($FreeSpace -lt $WarningLevel) {
|
||||
write-warning "Drive $Drive has only $FreeSpace GB free space left! (warning level is < $WarningLevel GB)"
|
||||
exit 1
|
||||
}
|
||||
write-host -foregroundColor green "OK - drive $Drive has $FreeSpace GB free space left (warning level is < $WarningLevel GB)"
|
||||
exit 0
|
||||
} catch {
|
||||
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user