mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-11 16:39:10 +01:00
Update check-drives.ps1
This commit is contained in:
parent
e192342523
commit
1a83a3032d
@ -1,8 +1,8 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks the free space of all drives
|
Checks the drive space
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script checks all drives for free space left (10 GB by default).
|
This PowerShell script checks all drives for free space left.
|
||||||
.PARAMETER MinLevel
|
.PARAMETER MinLevel
|
||||||
Specifies the minimum warning level (10 GB by default)
|
Specifies the minimum warning level (10 GB by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
@ -24,10 +24,12 @@ try {
|
|||||||
[int]$Used = $Details.Used / 1GB
|
[int]$Used = $Details.Used / 1GB
|
||||||
[int]$Total = ($Used + $Free)
|
[int]$Total = ($Used + $Free)
|
||||||
|
|
||||||
if ($Total -eq "0") {
|
if ($Total -eq 0) {
|
||||||
"✅ Drive $ID is empty."
|
"✅ Drive $ID is empty."
|
||||||
} elseif ($Free -lt $MinLevel) {
|
} elseif ($Free -lt $MinLevel) {
|
||||||
"⚠️ Drive $ID has only $Free GB of $Total GB left to use!"
|
"⚠️ Drive $ID has only $Free GB of $Total GB left to use!"
|
||||||
|
} elseif ($Used -lt $Free) {
|
||||||
|
"✅ Drive $ID uses $Used GB of $Total GB."
|
||||||
} else {
|
} else {
|
||||||
"✅ Drive $ID has $Free GB of $Total GB left."
|
"✅ Drive $ID has $Free GB of $Total GB left."
|
||||||
}
|
}
|
||||||
@ -36,4 +38,4 @@ try {
|
|||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user