module Jamf::MacOSRedeployMgmtFramework::ClassMethods

Class Methods

Public Class Methods

extended(extender) click to toggle source

when this module is included, also extend our Class Methods

   # File lib/jamf/api/jamf_pro/mixins/macos_redeploy_mgmt_framework.rb
49 def self.extended(extender)
50   Jamf.load_msg "--> #{extender} is extending #{self}"
51 end

Public Instance Methods

redeploy_mgmt_framework(target_ids, cnx: Jamf.cnx) click to toggle source

Redeploy the Jamf Management framework to target Computers or members of ComputerGroups

IMPORTANT: This only re-deploys the Jamf binary and related framework. The MDM system must be functioning. The target computer(s) will not re-install the framework if they never recieve the MDM command.

@param target_ids [String, Integer, Array<String, Integer>] Jamf IDs for the

Computer or ComputerGroup targets.

@param cnx [Jamf::Connection] The API connection to use. Defaults to Jamf.cnx

@return [Hash{Integer => String}] The result for each computer, either the

uuid of the sent MDM command, or an error message.
   # File lib/jamf/api/jamf_pro/mixins/macos_redeploy_mgmt_framework.rb
67 def redeploy_mgmt_framework(target_ids, cnx: Jamf.cnx)
68   target_ids = target_ids.is_a?(Array) ? target_ids : [target_ids]
69   target_comp_ids =
70     if self == Jamf::Computer
71       target_ids
72 
73     elsif self == Jamf::ComputerGroup
74       group_ids = target_ids.is_a?(Array) ? target_ids : [target_ids]
75       comp_ids = []
76       group_ids.each { |gid| comp_ids += JSS::ComputerGroup.fetch(id: gid).member_ids }
77       comp_ids
78 
79     else
80       raise Jamf::UnsupportedError, 'This method is only available for Jamf::Computer and Jamf::ComputerGroup'
81     end
82 
83   results = {}
84 
85   target_comp_ids.uniq.compact.each do |comp_id|
86     result = cnx.jp_post "#{REDEPLOY_RSRC}/#{comp_id}", Jamf::BLANK
87 
88     result = Jamf::OAPISchemas::RedeployJamfManagementFrameworkResponse.new result
89     results[comp_id] = result.commandUuid
90   rescue Jamf::Connection::JamfProAPIError => e
91     results[comp_id] = "ERROR: #{e}"
92   end
93 
94   results
95 end