Update check-dns.ps1, check-drives.ps1, and check-smart-devices.ps1

This commit is contained in:
Markus Fleschutz
2022-10-09 19:40:51 +02:00
parent 357a6f2fbb
commit 3375e6db6e
3 changed files with 14 additions and 13 deletions

View File

@ -3,6 +3,8 @@
Checks the free space of all drives
.DESCRIPTION
This PowerShell script checks all drives for free space left (20 GB by default).
.PARAMETER MinLevel
Specifies the minimum warning level (10 GB by default)
.EXAMPLE
PS> ./check-drives
.LINK
@ -11,7 +13,7 @@
Author: Markus Fleschutz | License: CC0
#>
param([int]$MinLevel = 50) # 50 GB minimum
param([int]$MinLevel = 10) # 10 GB minimum
try {
$Drives = Get-PSDrive -PSProvider FileSystem
@ -22,16 +24,15 @@ try {
[int]$Total = ($Used + $Free)
if ($Total -eq "0") {
$Reply = "✅ Drive $($Drive.Name) is empty."
"✅ Drive $($Drive.Name) is empty."
} elseif ($Free -lt $MinLevel) {
$Reply = "⚠️ Drive $($Drive.Name) has only $Free GB left to use! $Used of $Total GB is in use."
"⚠️ Drive $($Drive.Name) has only $Free GB left to use! $Used of $Total GB is in use."
} else {
$Reply = "✅ Drive $($Drive.Name) has $($Free) GB left, $($Total) GB total."
"✅ Drive $($Drive.Name) has $($Free) GB left, $($Total) GB total."
}
"$Reply"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
}