0

I'm trying to find on a Mac computer if the current user has iCloud Documents enabled. I found the plist where this is located (MobileMeAccounts.plist), but I could use some help with creating a script that can identify if it is enabled or not.

I am specifically looking for the following code to be true:

<key>Enabled</key>
<true/>

Here is the plist. If you scroll down you'll see the "MOBILE_DOCUMENTS" with it being enabled:

<?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>Accounts</key>
<array>
  <dict>
    <key>AccountAlternateDSID</key>
    <string>99999999</string>
    <key>AccountDSID</key>
    <string>999999</string>
    <key>AccountDescription</key>
    <string>iCloud</string>
    <key>AccountID</key>
    <string>*****@gmail.com</string>
    <key>AccountUUID</key>
    <string>9999999</string>
    <key>DisplayName</key>
    <string>User Name</string>
    <key>LoggedIn</key>
    <true/>
    <key>Services</key>
    <array>
        <dict>
            <key>Name</key>
            <string>CLOUDDESKTOP</string>
            <key>ServiceID</key>
            <string>com.apple.Dataclass.CloudDesktop</string>
            <key>status</key>
            <string>active</string>
        </dict>
        <dict>
            <key>Name</key>
            <string>FAMILY</string>
            <key>ServiceID</key>
            <string>com.apple.Dataclass.Family</string>
            <key>showManageFamily</key>
            <true/>
        </dict>
        <dict>
            <key>Enabled</key>
            <true/>
            <key>Name</key>
            <string>MOBILE_DOCUMENTS</string>
            <key>ServiceID</key>
            <string>com.apple.Dataclass.Ubiquity</string>
            <key>apsEnv</key>
            <string>production</string>
            <key>authMechanism</key>
            <string>token</string>
            <key>url</key>
            <string>https://p48-ubiquity.icloud.com:443</string>
            <key>wsUrl</key>
            <string>https://p48-ubiquityws.icloud.com:443</string>
        </dict>
Dan
  • 1,709
  • 5
  • 15
  • 21

1 Answers1

0

Python includes a module for parsing plists. Probably you'll want some better error checking, but to demonstrate:

$ cat parseplist.py
import plistlib
pl = plistlib.readPlist("the_plist.xml")
print pl['Accounts'][0]['Services'][2]['Enabled']

$ python parseplist.py 
True
jas
  • 10,715
  • 2
  • 30
  • 41