Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cf52d4
commit 084f155
Showing
1 changed file
with
7 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
function WriteBatteryPercent ([int]$Append, [int]$Sleep) { | ||
function WriteBatteryPercent ([int]$Append) { | ||
if ($Append -ne 0) { | ||
Write-Output (([string](Get-WmiObject Win32_Battery).EstimatedChargeRemaining) + ';' + (Get-Date -Format "%H:%m:s")) ` | ||
| Tee-Object -Filepath "battery_test_log.txt" -Append; | ||
} else { | ||
Write-Output (([string](Get-WmiObject Win32_Battery).EstimatedChargeRemaining) + ';' + (Get-Date -Format "%H:%m:s")) ` | ||
| Tee-Object -Filepath "battery_test_log.txt"; | ||
} | ||
if ($Sleep -ne 0) { | ||
Start-Sleep -s $Sleep | ||
} | ||
} | ||
|
||
Write-Output "battery percentage;time" | Tee-Object -Filepath "battery_test_log.txt"; | ||
$BatteryPercent = (Get-WmiObject Win32_Battery).EstimatedChargeRemaining; | ||
WriteBatteryPercent -Append 0 -Sleep 10; | ||
if (-not (Test-Path -LiteralPath "battery_test_log.txt" -PathType Leaf)) { | ||
Write-Output "battery percentage;time" | Tee-Object -Filepath "battery_test_log.txt"; | ||
WriteBatteryPercent -Append 0 -Sleep 10; | ||
} | ||
|
||
|
||
while ($true) { ` | ||
if ($BatteryPercent -ne (Get-WmiObject Win32_Battery).EstimatedChargeRemaining) { | ||
$BatteryPercent = (Get-WmiObject Win32_Battery).EstimatedChargeRemaining; | ||
WriteBatteryPercent -Append 1 -Sleep 10; | ||
WriteBatteryPercent -Append 1; | ||
} | ||
Start-Sleep -s 10; | ||
} | ||
|
||
pause; |