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

Commit fc5c726

Browse files
rashil2000JanDeDobbeleer
authored andcommitted
Slight speed improvement
1 parent 47a23d2 commit fc5c726

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Helpers/Prompt.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ function Set-Newline {
230230

231231
function Get-BatteryInfo {
232232
if ($env:OS -eq 'Windows_NT' -or $IsWindows) {
233-
234-
$batteryclass = Get-CimInstance win32_battery
233+
$cimSession = New-CimSession
234+
$batteryclass = Get-CimInstance win32_battery -Property EstimatedChargeRemaining -CimSession $cimSession
235235
if (!$batteryclass) { return }
236236

237-
$powerclass = Get-CimInstance -Class batterystatus -Namespace root\wmi
237+
$powerclass = Get-CimInstance -Class batterystatus -Namespace root\wmi -Property PowerOnline,Charging -CimSession $cimSession
238238
$charge = $batteryclass.EstimatedChargeRemaining
239239
$connected = $powerclass.PowerOnline
240240
$charging = $powerclass.Charging

0 commit comments

Comments
 (0)