Mah*_*kar 3 windows powershell wmi battery bluetooth
我正在尝试绘制蓝牙耳机电池放电图表。为此,我需要读取所连接设备的电池百分比。我可以在设备的 GUI 上看到电源信息。有没有办法使用 PowerShell 获取连接的蓝牙设备的电池百分比信息?(比如使用 wmi 或其他任何东西)
小智 6
根据我的发现,您可以使用 Get-PnpDevice cmdlet 获取有关蓝牙设备的信息。这应该返回 PnP 设备及其状态、类、FriendlyName 和 InstanceID 的列表。
Get-PnpDevice
Run Code Online (Sandbox Code Playgroud)
您可以使用 -Class 参数过滤结果。要指定蓝牙 PnP 设备,您可以输入“Bluetooth”作为 -Class 参数的字符串值。
Get-PnpDevice -Class 'Bluetooth'
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用 -FriendlyName 参数通过其FriendlyName 从此列表中指定您想要的设备,并输入所需设备的FriendlyName 作为参数的字符串值。
Get-PnpDevice -Class 'Bluetooth' -FriendlyName 'Device FriendlyName'
Run Code Online (Sandbox Code Playgroud)
注意:您还可以使用 -InstanceId 参数指定设备,并将设备的 InstanceId 作为参数的字符串值提供。
如果随后将上一个命令通过管道传递给 Get-PnpDeviceProperty cmdlet,它将返回设备属性的列表,包括其 InstanceId、KeyName、Type 和 Data。
Get-PnpDevice -Class 'Bluetooth' -FriendlyName 'Device FriendlyName' |
Get-PnpDeviceProperty
Run Code Online (Sandbox Code Playgroud)
除此之外,我还可以通过使用 -KeyName 参数并输入(我假设)包含设备电源数据的属性的 KeyName 作为参数的字符串值来进一步过滤命令的结果。
Get-PnpDevice -Class 'Bluetooth' -FriendlyName 'Device FriendlyName' |
Get-PnpDeviceProperty -KeyName 'PropertyKeyName'
Run Code Online (Sandbox Code Playgroud)
不幸的是,这就是我所能解决的问题。希望我的贡献有所帮助。
归档时间: |
|
查看次数: |
4347 次 |
最近记录: |