Getting Data In

Do not run Powershell script when Splunk starts

splunk310805
New Member

Hi,

I want to run a Powershell script on a Windows universal forwarder according to a cron schedule. My input looks similar to this

[powershell://Test]
script = . "$SplunkHome\etc\apps\test\bin\test.ps1"
schedule = */15 * * * *
index = test

Besides running every 15 minutes as it should, I noticed that the script also runs every time when Splunk starts. Reading https://docs.splunk.com/Documentation/Splunk/latest/Admin/Inputsconf it says: "Regardless of which option you choose, the command or script always runs once when the instance starts."

I don't want that. I don't want the script to run when Splunk starts. Is there any way to disable that?

Labels (2)
0 Karma

livehybrid
Super Champion

Hi @splunk310805 

Its my understanding that this was previously raised as a bug (SPL-141385) which has now been updated in the docs to mention that it will run at startup too. (See https://community.splunk.com/t5/Getting-Data-In/Powershell-script-input-on-a-schedule/m-p/369941#M67...)

Unfortunately the only current workaround for this is to incorporate status checking in the powershell itself, this could be by checking the time since the last execution (e.g. comparison with last modified log file) or by checking that it is expected at a specific time (e.g. if you did 0,15,30,45 in cron schedule you could check its one of these times.

Its not great, but hopefully this helps!

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma
Get Updates on the Splunk Community!

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...

Splunk Up Your Game: Why It's Time to Embrace Python 3.9+ and OpenSSL 3.0

Did you know that for Splunk Enterprise 9.4, Python 3.9 is the default interpreter? This shift is not just a ...