Home > database >  Extract specific data from PowerShell output
Extract specific data from PowerShell output

Time:04-22

I need to get the specific value from powershell output. I need to get the numeric values in poewershell only.

$result =WMIC PATH Win32_Battery Get EstimatedChargeRemaining Output

CodePudding user response:

Instead of using wmic you can use a PowerShell built-in cmdlet to query WMI and CIM:

(Get-CimInstance -ClassName Win32_Battery).EstimatedChargeRemaining

See Get-CimInstance for Official Documentation.

  • Related