mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-02 10:59:14 +01:00
Add check-battery.ps1
This commit is contained in:
parent
cbf046ba3e
commit
1af1b6acaf
30
Scripts/check-battery.ps1
Normal file
30
Scripts/check-battery.ps1
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Checks the battery status
|
||||||
|
.DESCRIPTION
|
||||||
|
This PowerShell script checks and prints the battery status.
|
||||||
|
.EXAMPLE
|
||||||
|
PS> ./check-battery
|
||||||
|
.LINK
|
||||||
|
https://github.com/fleschutz/PowerShell
|
||||||
|
.NOTES
|
||||||
|
Author: Markus Fleschutz | License: CC0
|
||||||
|
#>
|
||||||
|
|
||||||
|
try {
|
||||||
|
Add-Type -Assembly System.Windows.Forms
|
||||||
|
$Details = [System.Windows.Forms.SystemInformation]::PowerStatus
|
||||||
|
switch ($Details.PowerLineStatus) {
|
||||||
|
"Online" { $PowerStatus = "Plugged in to AC power" }
|
||||||
|
"Offline" { $PowerStatus = "Disconnected from AC power" }
|
||||||
|
}
|
||||||
|
switch ($Details.BatteryChargeStatus) {
|
||||||
|
"NoSystemBattery" { $BatteryStatus = "no system battery" }
|
||||||
|
default { $BatteryStatus = $Details.BatteryChargeStatus }
|
||||||
|
}
|
||||||
|
"✅ $PowerStatus, $BatteryStatus"
|
||||||
|
exit 0 # success
|
||||||
|
} catch {
|
||||||
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
exit 1
|
||||||
|
}
|
@ -12,15 +12,16 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
" "
|
" "
|
||||||
" ⭐️HARDWARE⭐️"
|
& "$PSScriptRoot/write-green.ps1" " H A R D W A R E"
|
||||||
& "$PSScriptRoot/check-cpu.ps1"
|
& "$PSScriptRoot/check-cpu.ps1"
|
||||||
& "$PSScriptRoot/check-ram.ps1"
|
& "$PSScriptRoot/check-ram.ps1"
|
||||||
& "$PSScriptRoot/check-gpu.ps1"
|
& "$PSScriptRoot/check-gpu.ps1"
|
||||||
& "$PSScriptRoot/check-bios.ps1"
|
& "$PSScriptRoot/check-bios.ps1"
|
||||||
& "$PSScriptRoot/check-smart-devices.ps1"
|
& "$PSScriptRoot/check-smart-devices.ps1"
|
||||||
& "$PSScriptRoot/check-drives.ps1"
|
& "$PSScriptRoot/check-drives.ps1"
|
||||||
|
& "$PSScriptRoot/check-battery.ps1"
|
||||||
" "
|
" "
|
||||||
" ⭐️SOFTWARE⭐️"
|
& "$PSScriptRoot/write-green.ps1" " S O F T W A R E"
|
||||||
& "$PSScriptRoot/check-operating-system.ps1"
|
& "$PSScriptRoot/check-operating-system.ps1"
|
||||||
& "$PSScriptRoot/check-uptime.ps1"
|
& "$PSScriptRoot/check-uptime.ps1"
|
||||||
& "$PSScriptRoot/check-time-zone.ps1"
|
& "$PSScriptRoot/check-time-zone.ps1"
|
||||||
|
@ -39,7 +39,7 @@ if ($Line1 -eq "") {
|
|||||||
$Line5 = "Best regards,"
|
$Line5 = "Best regards,"
|
||||||
$Line6 = "Markus"
|
$Line6 = "Markus"
|
||||||
}
|
}
|
||||||
write-host ""
|
|
||||||
WriteLine $Line1 $Speed
|
WriteLine $Line1 $Speed
|
||||||
WriteLine $Line2 $Speed
|
WriteLine $Line2 $Speed
|
||||||
WriteLine $Line3 $Speed
|
WriteLine $Line3 $Speed
|
||||||
@ -49,5 +49,4 @@ WriteLine $Line6 $Speed
|
|||||||
WriteLine $Line7 $Speed
|
WriteLine $Line7 $Speed
|
||||||
WriteLine $Line8 $Speed
|
WriteLine $Line8 $Speed
|
||||||
WriteLine $Line9 $Speed
|
WriteLine $Line9 $Speed
|
||||||
write-host ""
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
|
Loading…
Reference in New Issue
Block a user