Getting Data In

How should you specify the script file for PowerShell Modular Inputs

Explorer

The documentation for the PowerShell Modular Input states When you specify a script file (.ps1), prepend the script name with a period and a space (". ")

This is dot sourcing the script and means that any script scope variables will persist after the script has completed and can lead to subtle bugs during subsequent executions of the script. I think it would be better to use the call operator & instead. Read the
PowerShell about_Operators documentation for the details about these operators.

This applies to the documenation for 6.3.1 through to 6.5 when I last checked.

0 Karma

Explorer

I'm pretty sure the & call operator is the right way to go and using & definitely works. Looking at the comments in the documentation, it looks like a user suggested using the . dot source operator and a moderator accepted this suggestion without understanding the difference.

For some reason the hyperlinks are not working in the question markdown so I'm repeating them here

Splunk documentation for the PowerShell Modular Input
PowerShell Operators documentation
PowerShell Scopes documentation

0 Karma

Community Manager
Community Manager

Hi @martinho

Your hyperlinks won't appear because you need a minimum of at least 50 karma points to post live links. You're going to have to edit your answer and actually paste the URLs you're trying to share with the community so people can copy and paste it themselves.

0 Karma

Explorer

@ppablo I don't have enough reputation to make more than 2 posts / edits a day. Sigh - the troubles of a second class citizien...

0 Karma

Explorer

Ah - interesting. Thanks for the insight. Pretty poor user experience though 🙂
Looks like this site is an older self hosted version of the Stack Exchange engine. Might have been better to go with a hosted version so it gets maintained.

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!