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.

8 REPLIES 8

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 :)

spesh
New Contributor III

In case anyone else comes across this thread, system_profiler SPManagedClientDataType command may also come in handy.

tkimpton
Valued Contributor II

ive tried looking at that on macOS 15 but come back with nothing

sdagley
Esteemed Contributor II

@tkimpton What version of macOS 15 are you running? Running "system_profiler SPManagedClientDataType" in Terminal on macOS 15.1 works for me.

tkimpton
Valued Contributor II

ah it seems you can't run it as root user which sucks. Would have been good to use it in some workflows.