Skip to main content
Question

Read values from configuration profile via terminal/script?


Forum|alt.badge.img+3

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

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3532 replies
  • October 20, 2018

@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
Forum|alt.badge.img+36
  • Legendary Contributor
  • 1900 replies
  • October 20, 2018

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

bpavlov
Forum|alt.badge.img+18
  • Esteemed Contributor
  • 1206 replies
  • October 21, 2018

Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 2 replies
  • October 22, 2018

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


spesh
Forum|alt.badge.img+8
  • Jamf Heroes
  • 24 replies
  • October 9, 2024

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


Forum|alt.badge.img+21
  • Honored Contributor
  • 970 replies
  • November 5, 2024
spesh wrote:

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


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


sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3532 replies
  • November 5, 2024
tkimpton wrote:

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


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


Forum|alt.badge.img+21
  • Honored Contributor
  • 970 replies
  • November 6, 2024

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings