Posted on 10-19-2018 02:45 PM
I see a lot of threads on how to show some information about installed profiles using the profiles command.
Anybody know how I can use bash to read specific values from a profile?
I want to use it to get a configured server URL that is only easily available via configuration profile on a freshly deployed system.
Posted on 10-19-2018 07:53 PM
@nathan.perkins You aren't going to be able to access the profile itself after installation (at least as of High Sierra), but if you know what domain the profile was going to modify you should find the .plist with those settings in /Library/Managed Preferences/
and you can read them with the defaults
tool.
Posted on 10-20-2018 07:00 AM
While it's not possible to directly read a configuration profile when it's installed, it's still possible read the active settings for a domain. For example, if you specify a specific Safari HomePage in a configuration profile but the user hasn't, the following one-liner will still read the com.apple.Safari domain settings and return the configured HomePage.
You'll need to replace key
with the key in the plist or profile you're trying to read and you'll need to replace com.domain.app
with the domain the configuration profile is managing
python -c "from Foundation import CFPreferencesCopyAppValue; print CFPreferencesCopyAppValue('key', 'com.domain.app')"
Posted on 10-21-2018 07:34 AM
Posted on 10-22-2018 04:05 PM
Thank you all for your wonderful suggestions. I'll check them out :)
Posted on 10-09-2024 08:17 AM
In case anyone else comes across this thread, system_profiler SPManagedClientDataType command may also come in handy.
a month ago
ive tried looking at that on macOS 15 but come back with nothing
4 weeks ago
@tkimpton What version of macOS 15 are you running? Running "system_profiler SPManagedClientDataType" in Terminal on macOS 15.1 works for me.
4 weeks ago
ah it seems you can't run it as root user which sucks. Would have been good to use it in some workflows.