Getting Data In
Highlighted

When executing two different PowerShell scripts in inputs.conf, why does only one script work?

New Member

Hi
I'm trying to execute 2 different powershell scripts with different sourcetypes but on the same index. one of them is running but the second does not.

moreover, when i put one of the scripts in disabled=false and the other as true, it runs ok.

did it happen to someone?

0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

SplunkTrust
SplunkTrust

Can you share your input.conf configuration (for these two scripted input)?

0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

New Member

yeah sure, that's my input.conf:

First Script

[powershell://firstscript]
script= . "$SplunkHome/etc/.... firstScript.ps1"
index= first
script

schedule = 00 4 * * *

sourcetype= first_script
disabled = false

Second Script

[powershell://secondscript]
script= . "$SplunkHome/etc/.... secondScript.ps1"
index= second
script

schedule = 00 5 * * *

sourcetype= second_script
disabled = false

0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

Contributor

This happened to me a few months ago. I fixed it by creating a batch script to call the powershell script.

0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

New Member

but then can i make it with two different sourcetypes?

0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

Contributor

Yeah, using the same method you have above. Just replace the .ps1 with the .bat which calls the .ps1. You can keep the same sourcetypes or change them at your leisure.

0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

New Member

it brings me to splunk the bat text 😞

can you put you example please?

0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

Contributor

Sure, try something like this:

@echo off powershell.exe -ExecutionPolicy bypass -file "X:\Path\to\your\script.ps1"
0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

New Member

sorry for the delay,
I've just tried it but and it does the job this time but again only for one of the scripts

0 Karma
Highlighted

Re: When executing two different PowerShell scripts in inputs.conf, why does only one script work?

New Member

it parse each row as single event.
do you know what can I do about it?

0 Karma