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!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...