Battery monitoring tool for macOS deployed via Jamf Pro Self Service.
- Battery failure detection
- Health condition (Normal/Replace Soon/Service Battery)
- Cycle count vs. design limit
- Battery age calculation (when available)
- Current charge and power source
- Optional inventory update
- AppleCare coverage link on failure
- macOS 13.0+
- Jamf Pro agent
- MacBook/MacBook Air/MacBook Pro only
Settings → Computer Management → Scripts → New
- Name: Battery Health Check
- Script: Paste contents of
battery_health_check_v2.1.sh - Save
Computers → Policies → New
General:
- Name: Check Battery Health
- Trigger: None (Self Service only)
- Frequency: Ongoing
Scripts:
- Add: Battery Health Check
- Priority: After
Self Service:
- Make available in Self Service
- Display Name: Check Battery Health
- Description: View battery health including cycle count, charge status, and battery age
- Category: Utilities
Optional parameters for localization:
| Parameter | Purpose | Example |
|---|---|---|
| $5 | Coverage URL locale | https://checkcoverage.apple.com/?locale=es_ES |
| $6 | Battery icon path | /path/to/icon.icns |
| $7 | Coverage icon path | /path/to/icon.icns |
- Execution: ~2 seconds
- Data collection: 0.3 seconds (75% faster via single ioreg call)
- Memory: <20MB
No battery detected
Expected on desktop Macs (iMac, Mac mini, Mac Pro)
Inventory update fails
Check internet connection and verify Jamf agent: /usr/local/bin/jamf
Data collection error
Restart Mac or reset SMC (Intel only)
Testing:
bash -n battery_health_check_v2.1.sh # Syntax check
sudo ./battery_health_check_v2.1.sh # Run locallyVersion history:
See CHANGELOG.md
Contributing:
Test on macOS 13+ before submitting PRs
Battery age calculation
Apple encodes manufacture date as: (year - 1980) × 512 + month × 32 + day
Example: June 15, 2020 = 20,687
Note: May not be available on some M-series Macs.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | jamfHelper not found |
| 2 | No battery detected |
| 3 | Data collection failed |
MIT - see LICENSE
Ellie Romero
ellie@theecr.com
- Issues
- Discussions
- MacAdmins Slack - #jamf channel