Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
Slight speed improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
rashil2000 authored and JanDeDobbeleer committed Jan 10, 2021
1 parent 47a23d2 commit fc5c726
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Helpers/Prompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ function Set-Newline {

function Get-BatteryInfo {
if ($env:OS -eq 'Windows_NT' -or $IsWindows) {

$batteryclass = Get-CimInstance win32_battery
$cimSession = New-CimSession
$batteryclass = Get-CimInstance win32_battery -Property EstimatedChargeRemaining -CimSession $cimSession
if (!$batteryclass) { return }

$powerclass = Get-CimInstance -Class batterystatus -Namespace root\wmi
$powerclass = Get-CimInstance -Class batterystatus -Namespace root\wmi -Property PowerOnline,Charging -CimSession $cimSession
$charge = $batteryclass.EstimatedChargeRemaining
$connected = $powerclass.PowerOnline
$charging = $powerclass.Charging
Expand Down

0 comments on commit fc5c726

Please sign in to comment.