mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-14 06:48:46 +02:00
Update check-dns.ps1, check-drives.ps1, and check-smart-devices.ps1
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user