Can you update a script parameter in a policy via API?

brentac
New Contributor II

For a computer policy that has a script object in it, is it possible to update the script parameters via the API? I found in the classic api documentation (seen below) that you can update some parts of a policy with xml. Would it be possible to update a specific parameter (7 in this case) for a script. Ideally that would be the only thing that would change.

 

 

<policy>
    <general>
        <name>Firefox</name>
        <enabled>true</enabled>
        <trigger>string</trigger>
        <trigger_checkin>false</trigger_checkin>
        <trigger_enrollment_complete>false</trigger_enrollment_complete>
        <trigger_login>false</trigger_login>
        <trigger_logout>false</trigger_logout>
        <trigger_network_state_changed>false</trigger_network_state_changed>
        <trigger_startup>false</trigger_startup>
        <trigger_other>string</trigger_other>
        <frequency>Once per computer</frequency>
        <location_user_only>false</location_user_only>
        <target_drive>/</target_drive>
        <offline>false</offline>
        <category>
            <id>-1</id>
            <name>Unknown</name>
        </category>
        <network_limitations>
            <minimum_network_connection>No Minimum</minimum_network_connection>
            <any_ip_address>true</any_ip_address>
        </network_limitations>
        <network_requirements>Any</network_requirements>
        <site>
            <id>-1</id>
            <name>None</name>
        </site>
    </general>
    <scope>
        <all_computers>true</all_computers>
        <computers/>
        <computer_groups/>
        <buildings/>
        <departments/>
        <limit_to_users>
            <user_groups/>
        </limit_to_users>
        <limitations>
            <users/>
            <user_groups/>
            <network_segments/>
            <ibeacons/>
        </limitations>
        <exclusions>
            <computers/>
            <computer_groups/>
            <buildings/>
            <departments/>
            <users/>
            <user_groups/>
            <network_segments/>
            <ibeacons/>
        </exclusions>
    </scope>
    <self_service>
        <use_for_self_service>true</use_for_self_service>
        <self_service_display_name>Install Firefox</self_service_display_name>
        <install_button_text>Install</install_button_text>
        <reinstall_button_text>Reinstall</reinstall_button_text>
        <self_service_description>Install or update Firefox to version 48.0.2.</self_service_description>
        <force_users_to_view_description>false</force_users_to_view_description>
        <self_service_icon/>
        <feature_on_main_page>false</feature_on_main_page>
        <self_service_categories>
            <category>
                <id>1</id>
                <name>Applications</name>
                <display_in>true</display_in>
                <feature_in>false</feature_in>
            </category>
        </self_service_categories>
        <notification>false</notification>
        <notification>Self Service</notification>
        <notification_subject>Install Firefox</notification_subject>
        <notification_message/>
    </self_service>
</policy>

 

 

5 REPLIES 5

cbrewer
Valued Contributor II

Yes, it can be done. What language are you wanting to use? I'm doing it with powershell.

brentac
New Contributor II

Assuming it's XML that you're using, can you share how you have it set up?

cbrewer
Valued Contributor II

Here is a powershell example you can use. Set your jamf server info on lines 4-6. Then you'll want to set the variables on lines 70-74 before the setJamfScriptParam function runs.

 

https://github.com/cwmcbrewster/Jamf_API_Scripts/blob/master/jamf_api_set_policy_script_param.ps1 

brentac
New Contributor II

Thanks I’ll check this out. 

brentac
New Contributor II

Currently I'm writing all my scripts in bash because I'm very much a novice and that's what has clicked with me the best so far (probably because it’s the most simple from what I have gathered)