-
Notifications
You must be signed in to change notification settings - Fork 0
/
Battery_check.ps1
36 lines (28 loc) · 1.05 KB
/
Battery_check.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# скрипт запускающий тревогу при разряде АКБ
"run process battery control!"
while ($True)
{
# get battery charge and status power:
$charge = Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty EstimatedChargeRemaining
$value = Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty BatteryStatus
Start-Sleep -s 9
while (($charge -lt 15) -and ($value -eq 1))
{
"Current Charge: $charge %."
[console]::beep(500,300)
Start-Sleep -s 1
[console]::beep(460,220)
Start-Sleep -s 1
# снизим яркость
(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1,0)
$value = Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty BatteryStatus
"battery state: $value"
# подключили адаптер - сбрасываем тревогу
if ($value -eq 2)
{
"DC adapter connect"
(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1,75)
break
}
}
}