Getting Data In

SA-Modularinput-powershell (V3): scheduler fails scheduling with more than one stanza

forca
New Member

Hi.
We are running Splunk Enterprise version 7.2.0.
On this version and also on 6.6, we find that when we have more than one scheduled powershell input, the second fails with the following message in splunk-powershell.ps1.log:

ERROR User script exception: : The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services.

If any of the inputs are the only scheduled they run as expected.
The inputs are:

[powershell://FetchMachineCache_Contents_DMZ_Prod]
host = XXXX
index = looper
interval = 900
script = . "$SPLUNKHOME\bin\scripts\FetchMachineCache_Contents_DMZ_Prod.ps1"
disabled = 0

[powershell://FetchMachineCache_Contents_Prod]
host = XXXX
index = looper
interval = 180 
script = . "$SPLUNKHOME\bin\scripts\FetchMachineCache_Contents_Prod.ps1"
disabled = 0
0 Karma

forca
New Member

Update:

It turned out that the issue was that the powershell scripts used Invoke-Sqlcmdwhich is not thread-safe.
That caused the scripts to fail with the mentioned error.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

@forca, If your problem is resolved, please add some details to your answer to help others that might have the same problem. Then accept the answer.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...