Read values from configuration profile via terminal/script?

nathan_perkins
New Contributor II

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.

4 REPLIES 4

sdagley
Esteemed Contributor II

@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.

talkingmoose
Moderator
Moderator

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')"

nathan_perkins
New Contributor II

Thank you all for your wonderful suggestions. I'll check them out :)