-
Notifications
You must be signed in to change notification settings - Fork 47
/
Battery Health Status.xml
36 lines (30 loc) · 1.2 KB
/
Battery Health Status.xml
1
<?xml version="1.0" encoding="UTF-8"?><extensionAttribute> <displayName>Battery Health Status</displayName> <displayInCategory>System Information</displayInCategory> <dataType>string</dataType> <description>This attribute returns the health of the battery, if installed. In the event of battery failure, the attribute will report back "Failure". This attribute applies to both Mac and Windows.</description> <scriptContentsMac>#!/bin/shresult=`ioreg -r -c "AppleSmartBattery" | grep "PermanentFailureStatus" | awk '{print $3}' | sed s/\"//g`if [ "$result" == "1" ]; thenresult="Failure"elif [ "$result" == "0" ]; thenresult="OK"fiecho "<result>$result</result>" </scriptContentsMac> <scriptTypeWindows>VBScript</scriptTypeWindows> <scriptContentsWindows>On Error Resume NextDim objBatteriesDim strBatteries Set objBatteries = GetObject("winmgmts:").InstancesOf("Win32_Battery")i=0For each Battery in objBatteries if i <> 0 then strBatteries = "<br>" & strBatteries End if strBatteries = Battery.Status & strBatteries i = i + 1NextWScript.Echo "<result>" & strBatteries & "</result>"</scriptContentsWindows></extensionAttribute>