lib/jss/api_object/mdm.rb
def send_mdm_command(targets, command, opts: {}, api: JSS.api)
        command = validate_command(command)

        rsrc = "#{send_command_rsrc}/command/#{command}"

        targets = raw_targets_to_ids targets, api: api

        cmd_xml = mdm_command_xml(command, opts, targets)

        if JSS.devmode?
          puts "Sending XML:\n"
          REXML::Document.new(cmd_xml).write STDOUT, 2
          puts "\n\nTo rsrc: #{rsrc}"
        end

        result = api.post_rsrc rsrc, cmd_xml

        if command == BLANK_PUSH
          hash = {}
          targets.each { |t| hash[t] = BLANK_PUSH_RESULT }
        elsif COMPUTER_TARGETS.include? self::MDM_COMMAND_TARGET
          hash = process_computer_xml_result(result)
        elsif DEVICE_TARGETS.include? self::MDM_COMMAND_TARGET
          hash = process_mobiledevice_xml_result(result)
        end

        hash
      end
# Send an MDM command to one or more targets without instantiating them.
#
# This general class method, and all the specific ones that all it, have
# matching instance methods. Use the class method when you don't have, or
# don't want to retrieve, instances of all the targets.
#
# If you do have an instance or a target, call the matching instance method
# to send commands to that specific target.
#
# @example send a blank push to mobiledevice id 12 without instantiating:
#
#   JSS::MobileDevice.send_blank_push 12
#
# @example send a blank push to mobiledevice id 12 with instantiating:
#
#   device = JSS::MobileDevice.fetch id: 12
#   device.send_blank_push
#
# @example send a blank push to computers in computer groups
#   'SpecialMacs' and 'FooBarGroup'
#
#   JSS::ComputerGroup.send_blank_push ['SpecialMacs', 'FooBarGroup']
#
# @param targets[String,Integer,Array<String,Integer>]
#   the name or id of the device(s), or devicegroup(s) to receive the
#   command, or an array of such names or ids. NOTE: when calling this on a
#   Group class, the targets are the groups themselves, not the individual
#   members - the membership will be expanded.
#
# @param command[Symbol] the command to send, one of the keys
#   of COMMANDS
#
# @param opts[Hash] Some commands require extra data, e.g. a device name.
#   Put it here
#
# @param api[JSS::APIConnection] the API connection to use. Defaults to the
#   currently active API, see {JSS::APIConnection}
#
# @return [Hash{Integer=>String}] Keys are the target device ids.
#   Values depend on the kind of target:
#   - Computers will have the udid of the command sent to that computer.
#     The udid can be used to later retrieve info about the command.
#   - Mobile Devices seem to only have one command udid returned - for the
#     last device to have the command sent to it. (even in the Database,
#     not just in the API). So instead, the Hash value is the status of
#     the command for that device, most often 'Command sent'
#   Blank pushes do not generate return values, so Hash values are
#   always 'Command sent' (an error will be raised if there are problems
#   sending)
#
Send an MDM command to one or more targets without instantiating them.
This general class method, and all the specific ones that all it, have
matching instance methods. Use the class method when you don't have, or
don't want to retrieve, instances of all the targets.

If you do have an instance or a target, call the matching instance method
to send commands to that specific target.
Send an MDM command to one or more targets without instantiating them . This general class method and all the specific ones that all it have matching instance methods . Use the class method when you don ' t have or don ' t want to retrieve instances of all the targets . If you do have an instance or a target call the matching instance method to send commands to that specific target .
def send_mdm_command(targets, command, opts: {}, api: JSS.api)
        command = validate_command(command)
        rsrc = "#{send_command_rsrc}/command/#{command}"
        targets = raw_targets_to_ids targets, api: api
        cmd_xml = mdm_command_xml(command, opts, targets)
        if JSS.devmode?
          puts "Sending XML:\n"
          REXML::Document.new(cmd_xml).write STDOUT, 2
          puts "\n\nTo rsrc: #{rsrc}"
        end
        result = api.post_rsrc rsrc, cmd_xml
        if command == BLANK_PUSH
          hash = {}
          targets.each { |t| hash[t] = BLANK_PUSH_RESULT }
        elsif COMPUTER_TARGETS.include? self::MDM_COMMAND_TARGET
          hash = process_computer_xml_result(result)
        elsif DEVICE_TARGETS.include? self::MDM_COMMAND_TARGET
          hash = process_mobiledevice_xml_result(result)
        end
        hash
      end
def send_mdm_command ( targets , command , opts : { } , api : JSS . api ) command = validate_command ( command ) rsrc = "#{send_command_rsrc}/command/#{command}" targets = raw_targets_to_ids targets , api : api cmd_xml = mdm_command_xml ( command , opts , targets ) if JSS . devmode? puts "Sending XML:\n" REXML :: Document . new ( cmd_xml ) . write STDOUT , 2 puts "\n\nTo rsrc: #{rsrc}" end result = api . post_rsrc rsrc , cmd_xml if command == BLANK_PUSH hash = { } targets . each { | t | hash [ t ] = BLANK_PUSH_RESULT } elsif COMPUTER_TARGETS . include? self :: MDM_COMMAND_TARGET hash = process_computer_xml_result ( result ) elsif DEVICE_TARGETS . include? self :: MDM_COMMAND_TARGET hash = process_mobiledevice_xml_result ( result ) end hash end
Send an MDM command to one or more targets without instantiating them.
Send an MDM command to one or more targets without instantiating them .
Keys are the target device ids. Values depend on the kind of target: - Computers will have the udid of the command sent to that computer. The udid can be used to later retrieve info about the command. - Mobile Devices seem to only have one command udid returned - for the last device to have the command sent to it. (even in the Database, not just in the API). So instead, the Hash value is the status of the command for that device, most often 'Command sent' Blank pushes do not generate return values, so Hash values are always 'Command sent' (an error will be raised if there are problems sending)
Keys are the target device ids . Values depend on the kind of target : - Computers will have the udid of the command sent to that computer . The udid can be used to later retrieve info about the command . - Mobile Devices seem to only have one command udid returned - for the last device to have the command sent to it . ( even in the Database not just in the API ) . So instead the Hash value is the status of the command for that device most often ' Command sent ' Blank pushes do not generate return values so Hash values are always ' Command sent ' ( an error will be raised if there are problems sending )
Hash{Integer=>String}
targets
the name or id of the device(s), or devicegroup(s) to receive the command, or an array of such names or ids. NOTE: when calling this on a Group class, the targets are the groups themselves, not the individual members - the membership will be expanded.
the name or id of the device ( s ) or devicegroup ( s ) to receive the command or an array of such names or ids . NOTE : when calling this on a Group class the targets are the groups themselves not the individual members - the membership will be expanded .
command
the command to send, one of the keys of COMMANDS
the command to send one of the keys of COMMANDS
opts
Some commands require extra data, e.g. a device name. Put it here
Some commands require extra data e . g . a device name . Put it here
api
the API connection to use. Defaults to the currently active API, see {JSS::APIConnection}
the API connection to use . Defaults to the currently active API see { JSS :: APIConnection }
example
send a blank push to mobiledevice id 12 without instantiating: JSS::MobileDevice.send_blank_push 12
send a blank push to mobiledevice id 12 without instantiating : JSS :: MobileDevice . send_blank_push 12
example
send a blank push to mobiledevice id 12 with instantiating: device = JSS::MobileDevice.fetch id: 12 device.send_blank_push
send a blank push to mobiledevice id 12 with instantiating : device = JSS :: MobileDevice . fetch id : 12 device . send_blank_push
example
send a blank push to computers in computer groups 'SpecialMacs' and 'FooBarGroup' JSS::ComputerGroup.send_blank_push ['SpecialMacs', 'FooBarGroup']
send a blank push to computers in computer groups ' SpecialMacs ' and ' FooBarGroup ' JSS :: ComputerGroup . send_blank_push [ ' SpecialMacs ' ' FooBarGroup ' ]