从 PowerShell 输出中提取特定数据

Extract specific data from PowerShell output

我需要从 powershell 输出中获取特定值。我只需要在 poewershell 中获取数值。

$result =WMIC PATH Win32_Battery Get EstimatedChargeRemaining

您可以使用 PowerShell built-in cmdlet 来查询 WMI 和 CIM,而不是使用 wmic

(Get-CimInstance -ClassName Win32_Battery).EstimatedChargeRemaining

请参阅 Get-CimInstance 获取官方文档。