forked from jamf/Jamf-Nation-Extension-Attributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Battery Time Remaining.xml
28 lines (24 loc) · 1.04 KB
/
Battery Time Remaining.xml
1
<?xml version="1.0" encoding="UTF-8"?><extensionAttribute> <displayName>Battery Time Remaining</displayName> <displayInCategory>System Information</displayInCategory> <dataType>integer</dataType> <description>This attribute returns number of minutes of battery charge remaining, if a battery is installed. This attribute applies to both Mac and Windows.</description> <scriptContentsMac>#!/bin/shecho "<result>$(ioreg -r -c "AppleSmartBattery" | grep -w "TimeRemaining" | awk '{print $3}' | sed s/\"//g)</result>" </scriptContentsMac> <scriptTypeWindows>VBScript</scriptTypeWindows> <scriptContentsWindows>On Error Resume Next Dim objBatteriesDim strBatteries Set objBatteries = GetObject("winmgmts:").InstancesOf("Win32_Battery")i=0For each Battery in objBatteriesif i <> 0 thenstrBatteries = "<br>" & strBatteriesEnd If strBatteries = Battery.EstimatedRunTime & strBatteriesi=i+1NextWScript.Echo "<result>" & strBatteries & "</result>"</scriptContentsWindows></extensionAttribute>