Skip to content

Instantly share code, notes, and snippets.

@masterflitzer
Created March 13, 2023 19:32
Show Gist options
  • Save masterflitzer/aa4952dafe0272adbfd258e0518feaa7 to your computer and use it in GitHub Desktop.
Save masterflitzer/aa4952dafe0272adbfd258e0518feaa7 to your computer and use it in GitHub Desktop.
Log current battery charge on Windows
while ($true) {
$charge = Get-CimInstance -ClassName Win32_Battery | Select-Object -ExpandProperty EstimatedChargeRemaining
Write-Output "Current Charge: ${charge}%" | Tee-Object -Append "$([System.Environment]::GetFolderPath("Desktop"))/battery.log"
Start-Sleep -Seconds 30
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment