I am trying to use the PlistValueEquals function in a Custom Inventory Rule to check the value of an item but it won't work properly. I believe the issue is being caused by the value being nested inside of a dictionary. The plist looks like this:
Dict {
RepeatingPowerOn = Dict {
time = 1200
weekdays = 8
eventtype = wakepoweron
}
}
When I try to check the value for time it does not return properly. Even when using PlistValueReturn(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, time, NUMBER) to see what the value is I do not get anything back.
I have also tried PlistValueReturn(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, RepeatingPowerOn, TEXT) and this returns the following:
Dict {
time = 1260
weekdays = 8
eventtype = wakepoweron
} [string]
Note that in the database the value appears as:
'Dict {<br/> time = 1260<br/> weekdays = 8<br/> eventtype = wakepoweron<br/>}'
However, this rule:
PlistValueEquals(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, RepeatingPowerOn, TEXT, Dict {<br/> time = 1260<br/> weekdays = 8<br/> eventtype = wakepoweron<br/>})
does not work to identify machines with those settings.
We are trying to detect the power on settings for the machines in our inventory so that we can deploy the settings that we would like to be in place.
Solution:
By checking the syntax for the PlistBuddy command on macOS I found that you can query keys inside of a dictionary by using colons. The same syntax works for the Plist functions in custom inventory rules. Using that logic, this rule works:
PlistValueEquals(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, :RepeatingPowerOn:weekdays, NUMBER, 8) and PlistValueEquals(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, :RepeatingPowerOn:time, NUMBER, 1200) and PlistValueEquals(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, :RepeatingPowerOn:eventtype, TEXT, wakepoweron)
Comments