Skip to main content
Jamf Nation, hosted by Jamf, is a dynamic and knowledgeable community of Apple-focused IT admins and Jamf Pro users. Join us in person, in October, for the annual Jamf Nation User Conference (JNUC) to discover new and better ways to manage Apple devices.

Check if running on AC or Battery Power, and when this was checked.

Description

This is a sometimes handy Extension Attribute to avoid customers on laptops attempting to pull down sizable installations (Adobe CC, MATLab, OS X Upgrades, etc.) while running on the laptop battery. Use this to avoid installs interrupted by system sleep or a battery nearing exhaustion. This works for Desktops as well. They'll just always report "Now drawing from AC Power...". An example would be using as a policy exclusion for when a system was last reported as "Now drawing from Battery Power...". Insist the user Plug in the cord and update their inventory before being allowed to run the lengthy install. ########################################################### #!/bin/bash ########################################### # Check to see where power is being drawn # 'Battery Power' vs. 'AC Power' ########################################### # by Christopher Miller # for ITSD-ISS of JHU-APL # Dated: 2016-05-24, last Mod: 2016-05-24 # Cobbled together from other's hard work ########################################### #Use the power management to check PowerUP=$(pmset -g batt | head -n 1) #Find the time this was checked ShotTime=$(/bin/date) #Put it together result=$(echo "$PowerUP" on "$ShotTime") echo "<result>$result</result>" exit 0

Download

Preview

Generating Preview...

105 Downloads
Uploaded: 5/24/16 at 4:43 PM by clrlmiller
Product: Casper Suite