Get list of policies for a given Mac

eyemyth
New Contributor III

Hi all,

I would like to be able to get a list of policies and their triggers for a given machine. I've been poking around in the JSS API, but can't find a method of doing it.

The end goal is to have policies run at the login screen programmatically.

I attempted doing this with just ```
jamf policy
``` but it doesn't work the way it should. Example:

md-20013309:~ wgbhit$ sudo jamf policy
Checking for policies triggered by "any"...
Gathering Policy Information from https://[my casper server]
No Policies were found for the any trigger.
md-20013309:~ wgbhit$ sudo jamf policy -id 2243
Checking for policy ID 2243...
Gathering Policy Information from https://[my casper server]
Executing Policy TESTING Office remove and replace...

So, in my continuous uphill battle in the war against Casper, I want to get a list of policies a machine is waiting to run and feed those into the jamf binary.

2 REPLIES 2

mm2270
Legendary Contributor III

Unfortunately I don't see any way to do this. The API has no way of listing what Macs are scoped to a given policy, as far as I can see.
This is something I've also played around with also and finally gave up on. The trouble is that a given Mac has no clue what policies it needs to run until the specified trigger or timeframe is upon it and it checks in with your JSS for further instructions, or the event takes place, i.e. login/logout, etc.

Its possible the upcoming Casper Suite 9 may help with this a little, but I'm not sure, and even if I were I couldn't discuss it here anyway.

rockpapergoat
Contributor III

jay, there's probably some way to do this via the api or direct db queries, but neither option is very appealing.

i was thinking casper could use something simple like puppet's classes.txt or a --noop mode to test for applicable policies. jamf would do themselves and its community a great favor by incorporating ideas from real configuration management tools.