mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-28 01:28:50 +01:00
Rename to check-power.ps1
This commit is contained in:
parent
9fed276567
commit
a0344921e7
@ -22,5 +22,5 @@
|
|||||||
& "$PSScriptRoot/check-gpu.ps1"
|
& "$PSScriptRoot/check-gpu.ps1"
|
||||||
& "$PSScriptRoot/check-smart-devices.ps1"
|
& "$PSScriptRoot/check-smart-devices.ps1"
|
||||||
& "$PSScriptRoot/check-drives.ps1"
|
& "$PSScriptRoot/check-drives.ps1"
|
||||||
& "$PSScriptRoot/check-battery.ps1"
|
& "$PSScriptRoot/check-power.ps1"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks the battery
|
Checks the power status
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script queries the status of the system battery and prints it.
|
This PowerShell script queries the power status and prints it.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-battery.ps1
|
PS> ./check-power.ps1
|
||||||
⚠️ Battery 9% low, 54 min remaining
|
⚠️ Battery at 9% (54 min remaining) with power scheme: HP Optimized
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -30,19 +30,23 @@ try {
|
|||||||
}
|
}
|
||||||
} else { # must be offline
|
} else { # must be offline
|
||||||
if ($Remaining -eq 0) {
|
if ($Remaining -eq 0) {
|
||||||
$Reply = "✅ Battery at $Percent%, calculating remaining time..."
|
$Reply = "✅ Battery at $Percent%"
|
||||||
} elseif ($Remaining -le 5) {
|
} elseif ($Remaining -le 5) {
|
||||||
$Reply = "⚠️ Battery at $Percent%, ONLY $Remaining MIN remaining"
|
$Reply = "⚠️ Battery at $Percent% (ONLY $Remaining MIN remaining)"
|
||||||
} elseif ($Remaining -le 30) {
|
} elseif ($Remaining -le 30) {
|
||||||
$Reply = "⚠️ Battery at $Percent%, only $Remaining min remaining"
|
$Reply = "⚠️ Battery at $Percent% (only $Remaining min remaining)"
|
||||||
} elseif ($Percent -lt 10) {
|
} elseif ($Percent -lt 10) {
|
||||||
$Reply = "⚠️ Battery $Percent% low, $Remaining min remaining"
|
$Reply = "⚠️ Battery at $Percent% ($Remaining min remaining)"
|
||||||
} elseif ($Percent -ge 80) {
|
} elseif ($Percent -ge 80) {
|
||||||
$Reply = "✅ Battery $Percent% full, $Remaining min remaining"
|
$Reply = "✅ Battery $Percent% full ($Remaining min remaining)"
|
||||||
} else {
|
} else {
|
||||||
$Reply = "✅ Battery at $Percent%, $Remaining min remaining"
|
$Reply = "✅ Battery at $Percent% ($Remaining min remaining)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$PowerScheme = (powercfg /getactivescheme)
|
||||||
|
$PowerScheme = $PowerScheme -Replace "Power Scheme(.*) \(",""
|
||||||
|
$PowerScheme = $PowerScheme -Replace "\)$",""
|
||||||
|
$Reply += " with power scheme: $PowerScheme"
|
||||||
}
|
}
|
||||||
Write-Output $Reply
|
Write-Output $Reply
|
||||||
exit 0 # success
|
exit 0 # success
|
Loading…
Reference in New Issue
Block a user