In this post, I will show you how to check Mac battery condition using Intune. Using a custom attribute script, you can perform a battery health check for enrolled Mac devices with Intune.
Mac batteries, like all rechargeable batteries, lose efficiency over time. When you use your Mac laptop, its battery goes through charge cycles. Apple says that your battery is designed to retain up to 80 percent of its original capacity at 1,000 complete charge cycles. Post which you must consider replacing your battery when it reaches its maximum cycle count.
When you have a set of enrolled Mac devices assigned to your users, you may come across the battery health issues being reported. Instead of waiting for an email from users complaining about degrading battery life, administrators can proactively monitor battery health on Mac devices from Intune.
This is possible by deploying a custom attribute script that checks the battery condition on each Mac device and reports the health state in the Intune admin center. If you are new to custom attribute scripts, I have published a guide on creating custom attributes for macOS with Intune.
Manually Check battery health on Mac
Macbook users can manually check the battery’s health by selecting Apple menu > System Settings, then clicking Battery in the sidebar. In the below screenshot, the MacBook battery condition is normal.
Down below, you see the Maximum Capacity metric that often indicates the maximum charge your battery can hold compared to its original capacity.
Battery condition states for Mac
When you check the health of the Mac battery, you get to see it’s state. I have listed all the battery condition states and descriptions for Mac laptops in the table below.
Battery Condition State | Description |
---|---|
Normal | This indicates that your MacBook battery health is normal and suitable to use. |
Service recommended | This state indicates that the battery is performing normally, but its ability to hold a charge is less than when it was new. |
Replace soon | The battery’s health is deteriorating, and it’s losing the ability to hold a charge. |
Replace now | The battery’s health has deteriorated, and it needs to be replaced. |
Prerequisites
- The devices must be running macOS 12.0 or later.
- The macOS devices must be enrolled in Intune.
- Devices must be connected directly to the Internet. Connection through a proxy is not supported.
- You’ll need a valid custom attribute script to check Mac battery status, which is already provided in this guide.
GetMacBatteryCondition.sh script
The following custom attribute script checks and returns the battery condition of macOS devices. Copy and paste the below script to a file, and save the file as GetMacBatteryCondition.sh.
#!/bin/bash
#set -x
## Script that returns the macOS Battery Condition
batteryCondition=$(system_profiler SPPowerDataType | grep "Condition:" | sed 's/.*Condition: //')
echo $batteryCondition
Before uploading this script to Intune, you can test this script by manually running it on your Mac. Instead of a custom attribute, if you require a shell script to check the health of your Mac battery, please contact me and I will share it with you.
Check Mac Battery Condition using Intune
Let’s create a custom attribute policy in Intune for checking the battery condition of Mac devices. Sign in to the Intune admin center and go to Devices > By Platform > macOS. Under Organize devices > Custom attributes for macOS, click Create.
In the Basics tab, enter the following properties, and select Next:
- Name: Specify policy name.
- Description: Enter a description for the shell script. This setting is optional but recommended.
On the Attribute settings tab, upload the GetMacBatteryCondition.sh custom attribute script. Set the attribute type as String. Click Next.
In the Assignments tab, choose your target Mac device groups to assign the script policy. If you are testing this script in your organization, I recommend assigning it to a pilot device group that mostly includes the devices and users intended for testing. Upon successful deployment, you can expand the policy to larger groups.
Click Next to continue.
This is the last step where you review the profile settings. A summary of the policy settings that you’ve configured is presented on the screen. If everything looks good, click Add to save the script. The script you created now appears in the list of custom attributes.
You should see a new notification in the top-right corner of the Intune admin center: “Custom attribute successfully assigned.” The script policy is now deployed to the groups you selected.
Shell scripts provided in custom attribute profiles are run every 8 hours on managed Macs. To speed up your script testing, you can manually sync Intune policies on your Mac devices.
Monitor Mac battery health script policy
After you’ve assigned a custom attribute profile to your Mac groups, you can monitor its assignment in the Intune admin center.
In the Intune admin center, go to Devices > macOS > Organize devices > Custom attributes for macOS. On the right-hand side, select the Mac battery condition script policy. The Overview section displays the count of devices or users on which script execution was successful or failed.
To view the battery condition state of Mac devices, under Monitor, select Device Status. Here, the Status column shows whether the script execution was successful or failed. The Result column shows the battery health condition of the Mac device.
In the screenshot below, we see that the custom attribute script execution is successful on the Mac device and the battery state is reported as Normal.
Conclusion
In this guide, we learned about using a custom attribute script to determine the battery condition of Mac devices in Intune. Microsoft Intune allows users to easily check the condition of their batteries and take necessary actions to optimize performance. Regularly checking your battery condition through Intune can help you stay proactive in maintaining your device’s health, ensuring that you are always aware of its performance status.
Still Need Help?
If you need further assistance on the above article or want to discuss other technical issues, check out some of these options.