mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-04 22:38:34 +02:00
Update check-power.ps1
This commit is contained in:
parent
72b1203b26
commit
57c7be02c4
@ -5,7 +5,7 @@
|
|||||||
This PowerShell script queries the power status and prints it.
|
This PowerShell script queries the power status and prints it.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-power.ps1
|
PS> ./check-power.ps1
|
||||||
⚠️ Battery at 9% · 54 min remaining · power scheme 'HP Optimized'
|
⚠️ Battery at 9% with 54min remaining · power scheme 'HP Optimized'
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -34,21 +34,21 @@ try {
|
|||||||
} elseif ($remaining -eq 0) {
|
} elseif ($remaining -eq 0) {
|
||||||
$reply = "✅ Battery at $percent%"
|
$reply = "✅ Battery at $percent%"
|
||||||
} elseif ($remaining -le 5) {
|
} elseif ($remaining -le 5) {
|
||||||
$reply = "⚠️ Battery at $percent% · ONLY $($remaining)min remaining"
|
$reply = "⚠️ Battery at $percent% with ONLY $($remaining)min remaining"
|
||||||
} elseif ($remaining -le 30) {
|
} elseif ($remaining -le 30) {
|
||||||
$reply = "⚠️ Battery at $percent% · only $($remaining)min remaining"
|
$reply = "⚠️ Battery at $percent% with only $($remaining)min remaining"
|
||||||
} elseif ($percent -lt 10) {
|
} elseif ($percent -lt 10) {
|
||||||
$reply = "⚠️ Battery at $percent% · $($remaining)min remaining"
|
$reply = "⚠️ Battery at $percent% with $($remaining)min remaining"
|
||||||
} elseif ($percent -ge 60) {
|
} elseif ($percent -ge 80) {
|
||||||
$reply = "✅ Battery $percent% full · $($remaining)min remaining"
|
$reply = "✅ Battery $percent% full with $($remaining)min remaining"
|
||||||
} else {
|
} else {
|
||||||
$reply = "✅ Battery at $percent% · $($remaining)min remaining"
|
$reply = "✅ Battery at $percent% with $($remaining)min remaining"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$powerScheme = (powercfg /getactivescheme)
|
$powerScheme = (powercfg /getactivescheme)
|
||||||
$powerScheme = $powerScheme -Replace "^(.*) \(",""
|
$powerScheme = $powerScheme -Replace "^(.*) \(",""
|
||||||
$powerScheme = $powerScheme -Replace "\)$",""
|
$powerScheme = $powerScheme -Replace "\)$",""
|
||||||
$reply += " · power scheme '$powerScheme'"
|
$reply += ", power scheme is '$powerScheme'"
|
||||||
}
|
}
|
||||||
Write-Host $reply
|
Write-Host $reply
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
|
Loading…
Reference in New Issue
Block a user