<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Scripted input printing System.object[] instead of string? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Scripted-input-printing-System-object-instead-of-string/m-p/349561#M64156</link>
    <description>&lt;P&gt;I have a batch file that executes PowerShell like so:&lt;/P&gt;

&lt;P&gt;inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[script://.\bin\myscript.bat]
disabled = 0
interval = 60
index = main
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The script is (myscript.bat):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;type "%PROGRAMFILES%\Splunk\etc\apps\TA-myapp\bin\print-info.ps1" | powershell.exe -noprofile -
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The PowerShell we are executing is (print-info.ps1):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$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"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;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 &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;System.Object[]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I get Splunk to output the string that it's supposed to be outputting? &lt;/P&gt;

&lt;P&gt;We are unable to use the PowerShell modular input in our environment. &lt;/P&gt;</description>
    <pubDate>Thu, 19 Apr 2018 05:09:22 GMT</pubDate>
    <dc:creator>andrew207</dc:creator>
    <dc:date>2018-04-19T05:09:22Z</dc:date>
    <item>
      <title>Scripted input printing System.object[] instead of string?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Scripted-input-printing-System-object-instead-of-string/m-p/349561#M64156</link>
      <description>&lt;P&gt;I have a batch file that executes PowerShell like so:&lt;/P&gt;

&lt;P&gt;inputs.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[script://.\bin\myscript.bat]
disabled = 0
interval = 60
index = main
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The script is (myscript.bat):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;type "%PROGRAMFILES%\Splunk\etc\apps\TA-myapp\bin\print-info.ps1" | powershell.exe -noprofile -
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The PowerShell we are executing is (print-info.ps1):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$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"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;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 &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;System.Object[]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do I get Splunk to output the string that it's supposed to be outputting? &lt;/P&gt;

&lt;P&gt;We are unable to use the PowerShell modular input in our environment. &lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 05:09:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Scripted-input-printing-System-object-instead-of-string/m-p/349561#M64156</guid>
      <dc:creator>andrew207</dc:creator>
      <dc:date>2018-04-19T05:09:22Z</dc:date>
    </item>
  </channel>
</rss>

