M.H.C. is a Bash script that uses SwiftDialog alongside macOS internal commands to assess your MacBook’s health and replacement readiness. Designed for HelpDesk and end-users, it provides battery health metrics, device age, and an overall status in an interactive dialog.
- Battery Cycle Count with thresholds.
- Maximum Battery Capacity with health thresholds (%)
- Battery Condition check (Normal, Service recommended)
- Device Build Year and Age calculation
- Overall Status suggesting reuse, donation, or attention
- macOS (12.0+ recommended)
- SwiftDialog installed
- PLIstBuddy (built-in)
- jamf CLI (optional, for custom triggers)
-
Download the Script
wget https://raw.githubusercontent.com/teeles/macOSHealthCheck/refs/heads/MHC/macOSHealthCheck.sh
-
Make the script executable
chmod +x macOSHealthCheck.sh
-
Run the script:
./macOSHealthCheck.sh
- Upload
macOSHealthCheck.sh
as a Script in Jamf Pro. - Create a Policy scoped to your target machines.
- Add
macOSHealthCheck.sh
in the Scripts payload and add to self service so users can access whenever.
- Dialog Title & Icon: Edit the
--title
and--icon
flags in the final dialog command. - Button Actions: Update the
case
block for Button 2, 3, etc., to trigger logging or other workflows. - Health Thresholds: Modify the numeric bounds in
bat_cycle_count()
,bat_max_capacity()
, andmacage()
functions for custom cutoff values.
Function | Description |
---|---|
bat_cycle_count() |
Retrieves battery cycle count and outputs tiered actions based on thresholds |
bat_max_capacity() |
Checks battery maximum capacity (%) and outputs health status |
bat_condition() |
Reads battery condition (Normal, Service) |
macage() |
Calculates device age from build year and suggests replacement if older |
overall_status() |
Aggregates all checks to suggest reuse, donation, or service attention |
Dialog Launch | Uses SwiftDialog to present findings and buttons |
- Add Logging: Write health check outputs to
/var/log/mhc.log
- Button Two Function: Implement log file generation on Button 2 click
- Dependency Checks: Verify SwiftDialog presence at script start
- Expand Variables: Include CPU & memory checks