Module: Jamf::MacOSRedeployMgmtFramework::ClassMethods

Defined in:
lib/jamf/api/jamf_pro/mixins/macos_redeploy_mgmt_framework.rb

Overview

Class Methods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(extender) ⇒ Object

when this module is included, also extend our Class Methods



49
50
51
# File 'lib/jamf/api/jamf_pro/mixins/macos_redeploy_mgmt_framework.rb', line 49

def self.extended(extender)
  Jamf.load_msg "--> #{extender} is extending #{self}"
end

Instance Method Details

#redeploy_mgmt_framework(target_ids, cnx: Jamf.cnx) ⇒ Hash{Integer => String}

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.

Parameters:

  • target_ids (String, Integer, Array<String, Integer>)

    Jamf IDs for the Computer or ComputerGroup targets.

  • cnx (Jamf::Connection) (defaults to: Jamf.cnx)

    The API connection to use. Defaults to Jamf.cnx

Returns:

  • (Hash{Integer => String})

    The result for each computer, either the uuid of the sent MDM command, or an error message.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/jamf/api/jamf_pro/mixins/macos_redeploy_mgmt_framework.rb', line 67

def redeploy_mgmt_framework(target_ids, cnx: Jamf.cnx)
  target_ids = target_ids.is_a?(Array) ? target_ids : [target_ids]
  target_comp_ids =
    if self == Jamf::Computer
      target_ids

    elsif self == Jamf::ComputerGroup
      group_ids = target_ids.is_a?(Array) ? target_ids : [target_ids]
      comp_ids = []
      group_ids.each { |gid| comp_ids += JSS::ComputerGroup.fetch(id: gid).member_ids }
      comp_ids

    else
      raise Jamf::UnsupportedError, 'This method is only available for Jamf::Computer and Jamf::ComputerGroup'
    end

  results = {}

  target_comp_ids.uniq.compact.each do |comp_id|
    result = cnx.jp_post "#{REDEPLOY_RSRC}/#{comp_id}", Jamf::BLANK

    result = Jamf::OAPISchemas::RedeployJamfManagementFrameworkResponse.new result
    results[comp_id] = result.commandUuid
  rescue Jamf::Connection::JamfProAPIError => e
    results[comp_id] = "ERROR: #{e}"
  end

  results
end