2

I'm trying to search through files for a string given in parameters by NodeJS.

param(
    [switch]$raw,
    [string]$input
)

[string]$file = "*.log"
if($raw) { $file = ".\raws\*.log" }

Get-ChildItem -Recurse -Include $file | select-string $input

The problem is that I'm getting the error that $input is empty: PowerShell says $input is empty.

What am I doing wrong?

3

1 Answer 1

2

Thanks to @TessellatingHeckler for pointing out that $input is a reserved/automatic variable, and thus cannot be used like this.

Sign up to request clarification or add additional context in comments.

2 Comments

Oh man, such a lifesaver. I will note $profileName is also a reserved/automatic variable and I was having the same issue.
For anyone stumbling across this thread, here is a list of automatic variables in Powershell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.