- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 02-22-2023 02:50 AM
I've created this script in an Extension attribute but it's not showing.
#!/bin/bash
echo "<result>$(system_profiler SPPowerDataType | grep "Maximum Capacity:" | sed 's/.*Maximum Capacity: //')</result>"
exit 0
Could someone see what's the issue?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 02-22-2023 06:40 AM
Seems like the sed statement isn't working as intended...I'd suggest the following:
system_profiler SPPowerDataType | grep "Maximum Capacity:" | cut -d ":" -f2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 06:17 AM - edited 02-22-2023 06:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 02-22-2023 06:40 AM
Seems like the sed statement isn't working as intended...I'd suggest the following:
system_profiler SPPowerDataType | grep "Maximum Capacity:" | cut -d ":" -f2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 02-22-2023 07:11 AM
Thanks for the help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 02-22-2023 07:09 AM
Another caveat on that "system_profiler SPPowerDataType" command is that there's no "Maximum Capacity" in the output for non-laptop Macs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 02-22-2023 07:28 AM
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.