I've created this script in an Extension attribute but it's not showing.
echo "<result>$(system_profiler SPPowerDataType | grep "Maximum Capacity:" | sed 's/.*Maximum Capacity: //')</result>"
Could someone see what's the issue?
Solved! Go to Solution.
Has an inventory collection happened on at least one Mac yet? Because new EAs don't show any results until a Mac submits inventory and runs the script.
Edit: The other thing is, just running this command by itself - system_profiler SPPowerDataType | grep "Maximum Capacity:" | sed 's/.*Maximum Capacity: //' - doesn't yield any results for me. Are you sure this should be getting information you're looking for? You might need to double check your code.
The wording in the output also seems to have changed between OS versions, because why would Apple keep anything consistent? On my MBP running Monterey 12.6.3 it shows as "Full Charge Capacity". I haven't checked, but my assumption is the "Maximum Capacity" label is from Ventura?
In short, unless you have one OS version across the board and only laptops, you might want to put some checks into the EA so it can correctly return a value when it runs. Like, check the OS version and modify the grep string, or just grep for ".* Capacity" maybe, and also check the model identifier (if you have any desktops in the mix) and return N/A or something for those. Otherwise they will return a blank result.