Getting Data In

How should you specify the script file for PowerShell Modular Inputs

martinho
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

martinho
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

ppablo
Retired

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

martinho
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

martinho
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
Get Updates on the Splunk Community!

What's New in Splunk Cloud Platform 9.3.2411?

Hey Splunky People! We are excited to share the latest updates in Splunk Cloud Platform 9.3.2411. This release ...

Buttercup Games: Further Dashboarding Techniques (Part 6)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...