Create an ACC plugin package

task brazil Updated Oct 23, 2026 2 min read create-acc-plugin-structure.md
Raw file servicenow.com

Package a PowerShell script, a Ruby script, and an execution allowlist into an Agent Client Collector (ACC) plugin to run remedial actions on endpoints from the platform.

Before you begin

Role required: admin

Procedure

  1. Create a root folder for the ACC plugin on your local computer and name it.

    For example, acc-dex-custom.

  2. In the root folder, create two subfolders named allowlist and bin.

  3. Create a PowerShell script using PowerShell or command prompt commands to define the remedial action to run on an endpoint device.

    1. In the bin folder, create a file with the .ps1 extension.

      For example, CustomScript.ps1.

    2. Open the .ps1 file and add the commands.

      For example, the following sample .ps1 file defines a custom remedial action using commands to stop and start the W32Time process, pause, and restart the Spooler service on a device.

      PowerShell
      sc.exe stop w32time
      $process = Get-Process -Name w32time -ErrorAction SilentlyContinueif ($process) {    taskkill /f /t /im w32tm.exe}
      Start-Sleep -Seconds 5
      sc.exe start w32timeStart-Process "C:\Windows\System32\w32tm.exe"
      Start-Sleep -Seconds 5
      sc.exe stop spoolersc.exe start spooler

      Note: You can configure the PowerShell script to accept input parameters defined in the ServiceNow instance during execution.

    3. Save the file.

  4. Create a Ruby script to call the .ps1 file from the ServiceNow instance.

    1. In the bin folder, create a Ruby file and name it with the .rb extension.

    2. Open the .rb file and add your code using plain Ruby or any Ruby framework.

      The Ruby script must include the logic to:

      • Call the .ps1 script you created, making sure that you enter the correct file path.
      • Validate if the command is successfully executed.
      • Create an output JSON that includes the execution status, output, and errors, if any.
    3. Execute the command and review the output to confirm if the .ps1 file is called successfully or if there are any errors.

      For example, the following sample .rb file runs a .ps1 file (CustomScript.ps1) using the acc-f-commons plugin run command, validates if the command runs successfully, and returns the result JSON.

      Java
      require "logger"require_relative "../../../acc-f-commons/bin/command_runner.rb"require "json"
      class CustomScript  def initialize()    @logger = Logger.new(STDOUT)    @cmd_runner = CommandRunner.new    @logger.level = "FATAL"  end
        def execute_custom_script()    status = "failure"    msg = nil    data = {}
          parent_cache_directory = File.expand_path("../..", File.dirname(__FILE__)).gsub(" ", "` ")    query = "powershell -ExecutionPolicy Bypass " + parent_cache_directory + "/acc-dex-custom/bin/ps/customScript.ps1"
          output, error = @cmd_runner.runCmd(query, @logger, "mode con:cols=32766 lines=1 & chcp 65001 > nul & ", true, false)
          if !error && !output.empty?      status = "success"      msg = "Successfully ran script"      data = output    else      msg = "Failed - #{error}"    end
          result = {      "status" => status,      "type" => "device",      "metric_type" => "remedial_action",      "keys" => "custom_script",      "data" => data,      "message" => msg    }
          puts JSON.generate(result)  endend
      custom_script = CustomScript.newcustom_script.execute_custom_script()

      Note:

      If the PowerShell script is configured to accept input parameters from the ServiceNow instance, the Ruby script passes these parameters to the PowerShell script during execution.

  5. Create an allowlist file and specify the Ruby script permitted for execution on endpoint devices.

    1. In the allowlist subfolder, create an allowlist JSON file.

      For example, check-allowlist.json.

    2. Define any conditions such as arguments to be accepted as part of the .rb script, or create custom logic.

    3. Save the file.

  6. Generate a tar.gz file for your ACC plugin folder using any utility.

    Note: The tar.gz file name must match the plugin root folder name. For example, acc-dex-custom.tar.gz.

Keywords acc plugin packagecreate plugin structureacc pluginremedial action pluginpowershell remedial actionruby script plugin
Search documentation
Search document titles and file paths on the brazil branch