Need help with creating PLIST with nested keys

Rich_C
New Contributor III

I am trying to create a PLIST file that has nested Keys.  I have tried to use Default Writes, PUtil and Plistbuddy.  Below is what I am trying to accomplish in the plist file. Can someone please assist in the command to get this to work.

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
‹plist version="1.0">
‹dict>
           <key>DC</key>
            ‹dict>
                           <key>FeatureLockdown</key>
                           ‹dict>
                                            <key>bEnableGentech</key>
                                            ‹false/>
                                            < key>bUpdater</key>
                                            < false/>
                                            <key>bAcroSuppressUpsell</key>
                                            < false/>
                                </dict>
                    </dict>
</dict>

</plist>

1 ACCEPTED SOLUTION

oli
New Contributor III

This is exactly what I have done a few days before:

/usr/libexec/PlistBuddy -c "Add :DC dict" /Library/Preferences/com.adobe.Reader.plist
/usr/libexec/PlistBuddy -c "Add :DC:FeatureLockdown dict" /Library/Preferences/com.adobe.Reader.plist
/usr/libexec/PlistBuddy -c "Add :DC:FeatureLockdown:bEnableGentech bool false" /Library/Preferences/com.adobe.Reader.plist

View solution in original post

8 REPLIES 8

jamf-42
Valued Contributor II

do you need to create it dynamically? can't you make a config profile with Applications & Custom setting payload and upload / copy paste the plist ? (that plist above needs a bit of a tidy with the leading spaces) 

mm2270
Legendary Contributor III

For something with that type of complexity, I would probably create it directly using a script and the cat << EOD > /path/to/plist.plist method.

#!/bin/zsh

/bin/cat << EOPLIST > /path/to/something.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>DC</key>
		<dict>
			<key>FeatureLockdown</key>
				<dict>
					<key>bEnableGentech</key>
					<false/>
					<key>bUpdater</key>
					<false/>
					<key>bAcroSuppressUpsell</key>
					<false/>
				</dict>
		</dict>
</dict>
</plist>
EOPLIST

Getting this to work dynamically with defaults or any other tool is complicated. Not impossible, but in my opinion it isn't worth the struggle. It doesn't really look like there's anything in the plist that would vary during a deployment, but even if there was, you could replace some of the values with variables and pull those variables dynamically at script execution time.

Rich_C
New Contributor III

I thought about the creating payload but sometimes the plist has other settings and I am not 100% sure if it will append to the file.  As for the spaces in the file.  it is due to the way I had to put it in the post.  

mm2270
Legendary Contributor III

Hey @Rich_C when deploying a profile using the custom Applications and Settings payload like what @jamf-42 mentioned, it will not append to the plist, unless you change the plist itself in the profile. Otherwise, every time it's pushed it will just push the settings in their entirety to the client and overwrite anything that was there before.

I would consider using that method, or scripting it to write the plist in whole as I mentioned above, rather than trying to create the plist on the fly with individual defaults or PlistBuddy commands. Those tools are often good at extracting (reading) a plist values or injecting/changing a value to an existing plist, but aren't as good for creating a complex plist on the fly like that.

oli
New Contributor III

This is exactly what I have done a few days before:

/usr/libexec/PlistBuddy -c "Add :DC dict" /Library/Preferences/com.adobe.Reader.plist
/usr/libexec/PlistBuddy -c "Add :DC:FeatureLockdown dict" /Library/Preferences/com.adobe.Reader.plist
/usr/libexec/PlistBuddy -c "Add :DC:FeatureLockdown:bEnableGentech bool false" /Library/Preferences/com.adobe.Reader.plist

Rich_C
New Contributor III

Oli,  Thanks this is exactly what I was looking for.  I tested it and it worked perfectly and as expected.

oli
New Contributor III

A few years ago I figured out that PlistBuddy is the best way if it comes to complex plists.

The plist above is only used for Adobe Reader. There is another one for Acrobat Pro with the name com.adobe.Acrobat.Pro.plist in the same location. Both is what Adobe Enterprise Support told us to roll out.
In addition to this you can tell Adobe Enterprise Support to disable Generative AI Features for your entire Domain/Subdomains so it will be disabled based on a companies Adobe-ID login. This will only work for Acrobat Pro because you can't login to Adobe Reader.

Rich_C
New Contributor III

Yes, this post was originally was for the Acrobat.Pro plist but I also found out about the Adobe.Reader reader.  I was able to adjust what you gave me and test for both.  I like that it will append to or create the file if it does not exist.  Again, Thanks