Getting Data In

Scripted input printing System.object[] instead of string?

andrew207
Path Finder

I have a batch file that executes PowerShell like so:

inputs.conf

[script://.\bin\myscript.bat]
disabled = 0
interval = 60
index = main

The script is (myscript.bat):

type "%PROGRAMFILES%\Splunk\etc\apps\TA-myapp\bin\print-info.ps1" | powershell.exe -noprofile -

The PowerShell we are executing is (print-info.ps1):

$ProcessList = (Get-Process | select Name,Handle)
$ProcessList | Add-Member scriptmethod ToString { 'Name="{0}" Handle="{1}"' -f $this.Name, $this.Handle } -Force
$ProcessList.ToString() | Out-File -Append -NoClobber -Encoding utf8 -FilePath "$env:programfiles\Splunk\etc\apps\TA-myapp\spool\print-info.log"

If I execute the .BAT script manually (double clicking it), this works fine and the file is appended with text as I expect. If Splunk executes it, the file is instead appended with

System.Object[]

How do I get Splunk to output the string that it's supposed to be outputting?

We are unable to use the PowerShell modular input in our environment.

Get Updates on the Splunk Community!

Fueling your curiosity with new Splunk ILT and eLearning courses

At Splunk Education, we’re driven by curiosity—both ours and yours! That’s why we’re committed to delivering ...

Splunk AI Assistant for SPL 1.1.0 | Now Personalized to Your Environment for Greater ...

Splunk AI Assistant for SPL has transformed how users interact with Splunk, making it easier than ever to ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureOn Demand Now Step boldly into the AI revolution with enhanced security ...