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!

Demo Day: Strengthen Your SOC with Splunk Enterprise Security 8.1

Today’s threat landscape is more complex than ever. Security operation centers (SOCs) are overwhelmed with ...

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...