Splunk Dev

Getting the error: External search command 'testps' returned error code 1. .


I'm trying to run personal scripts in Splunk from a dashboard. I want the dashboard to call a script by user input and then output the script to a table. I'm testing the ability with a Python script that calls a PowerShell script, returns the data to the Python script, and then returns the data to the Splunk dashboard. This is what I have so far: 

Test_PowerShell.py Python Script: 


import splunk.Intersplunk
import sys
import subprocess

results,unused1,unused2 = splunk.Intersplunk.getOrganizedResults()

# Define the path to the PowerShell script
ps_script_path = "./Test.ps1"

# Define the argument to pass to the PowerShell script
argument = sys.argv[1]

# Execute the PowerShell script with the argument
results = subprocess.run(['powershell.exe', '-File', ps_script_path, argument], capture_output=True, text=True)



Page XML: 


<form version="1.1" theme="dark">
  <label>Compliance TEST</label>
  <fieldset submitButton="false" autoRun="false"></fieldset>
      <title>Input Panel</title>
      <input type="text" token="user_input">
        <label>User Input:</label>
      <title>Script Output</title>
          <query>| script python testps $user_input$ | table field1</query>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>


Test.ps1 PowerShell Script: 


Write-Host $args[0]




filename = Test_PowerShell.py
python.version = python3




access = read : [ * ], write : [ admin ]
export = system

access = read : [ * ], write : [ admin ]
export = system


The error I'm getting is the following: External search command 'testps' returned error code 1. 

Labels (3)
0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

 (view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...