mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-26 16:48:54 +01:00
Updated check-drives.ps1 and check-power.ps1
This commit is contained in:
parent
9a8ae08b77
commit
bae442ee81
@ -7,8 +7,8 @@
|
||||
Specifies the minimum warning level (10GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-drives.ps1
|
||||
✅ Drive C: at 49% of 1TB - 512GB free
|
||||
✅ Drive D: at 84% of 4TB - 641GB free
|
||||
✅ C: at 49% of 1TB - 512GB free
|
||||
✅ D: at 84% of 4TB - 641GB free
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -39,14 +39,14 @@ try {
|
||||
[int64]$total = ($used + $free)
|
||||
|
||||
if ($total -eq 0) {
|
||||
Write-Host "✅ Drive $name is empty"
|
||||
Write-Host "✅ $name is empty"
|
||||
} elseif ($free -eq 0) {
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is full"
|
||||
Write-Host "⚠️ $name with $(Bytes2String $total) is full"
|
||||
} elseif ($free -lt $minLevel) {
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
||||
Write-Host "⚠️ $name with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
||||
} else {
|
||||
[int64]$percent = ($used * 100) / $total
|
||||
Write-Host "✅ Drive $name at $percent% of $(Bytes2String $total) - $(Bytes2String $free) free"
|
||||
Write-Host "✅ $name at $percent% of $(Bytes2String $total) - $(Bytes2String $free) free"
|
||||
}
|
||||
}
|
||||
exit 0 # success
|
||||
|
@ -5,7 +5,7 @@
|
||||
This PowerShell script queries the power status and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-power.ps1
|
||||
⚠️ Battery at 9% with 54min remaining · power scheme 'HP Optimized'
|
||||
⚠️ Battery at 9% with power scheme 'HP Optimized' - 54min remaining
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -20,35 +20,34 @@ try {
|
||||
$details = [System.Windows.Forms.SystemInformation]::PowerStatus
|
||||
[int]$percent = 100 * $details.BatteryLifePercent
|
||||
[int]$remaining = $details.BatteryLifeRemaining / 60
|
||||
$powerScheme = (powercfg /getactivescheme)
|
||||
$powerScheme = $powerScheme -Replace "^(.*) \(",""
|
||||
$powerScheme = $powerScheme -Replace "\)$",""
|
||||
if ($details.PowerLineStatus -eq "Online") {
|
||||
if ($details.BatteryChargeStatus -eq "NoSystemBattery") {
|
||||
$reply = "✅ AC powered"
|
||||
} elseif ($percent -ge 95) {
|
||||
$reply = "✅ Battery $percent% full"
|
||||
$reply = "✅ Battery nearly full ($percent%, power scheme '$powerScheme')"
|
||||
} else {
|
||||
$reply = "✅ Battery charging ($percent%)"
|
||||
$reply = "✅ Battery charging ($percent%, power scheme '$powerScheme')"
|
||||
}
|
||||
} else { # must be offline
|
||||
if (($remaining -eq 0) -and ($percent -ge 60)) {
|
||||
$reply = "✅ Battery $percent% full"
|
||||
$reply = "✅ Battery $percent% full (power scheme '$powerScheme')"
|
||||
} elseif ($remaining -eq 0) {
|
||||
$reply = "✅ Battery at $percent%"
|
||||
$reply = "✅ Battery at $percent% (power scheme '$powerScheme')"
|
||||
} elseif ($remaining -le 5) {
|
||||
$reply = "⚠️ Battery at $percent% with ONLY $($remaining)min remaining"
|
||||
$reply = "⚠️ Battery at $percent% (power scheme '$powerScheme') - ONLY $($remaining)min remaining"
|
||||
} elseif ($remaining -le 30) {
|
||||
$reply = "⚠️ Battery at $percent% with only $($remaining)min remaining"
|
||||
$reply = "⚠️ Battery at $percent% (power scheme '$powerScheme') - only $($remaining)min remaining"
|
||||
} elseif ($percent -lt 10) {
|
||||
$reply = "⚠️ Battery at $percent% with $($remaining)min remaining"
|
||||
$reply = "⚠️ Battery at $percent% (power scheme '$powerScheme') - $($remaining)min remaining"
|
||||
} elseif ($percent -ge 80) {
|
||||
$reply = "✅ Battery $percent% full with $($remaining)min remaining"
|
||||
$reply = "✅ Battery $percent% full (power scheme '$powerScheme') - $($remaining)min remaining"
|
||||
} else {
|
||||
$reply = "✅ Battery at $percent% with $($remaining)min remaining"
|
||||
$reply = "✅ Battery at $percent% (power scheme '$powerScheme') - $($remaining)min remaining"
|
||||
}
|
||||
}
|
||||
$powerScheme = (powercfg /getactivescheme)
|
||||
$powerScheme = $powerScheme -Replace "^(.*) \(",""
|
||||
$powerScheme = $powerScheme -Replace "\)$",""
|
||||
$reply += ", power scheme is '$powerScheme'"
|
||||
}
|
||||
Write-Host $reply
|
||||
exit 0 # success
|
||||
|
Loading…
Reference in New Issue
Block a user