Bird
0
0

Why does this command fail?

medium📝 Debug Q7 of 15
PowerShell - String Operations
Why does this command fail?
Select-String -Pattern 'test' -Path 'file1.txt', 'file2.txt'
APattern must be a regex, not plain text
BQuotes around file names cause error
CSelect-String cannot search multiple files
DComma-separated file list is invalid syntax
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter value format

    -Path expects an array or single string, but comma-separated strings without array syntax cause error.
  2. Step 2: Correct way to specify multiple files

    Use an array like @('file1.txt','file2.txt') or separate strings properly.
  3. Final Answer:

    Comma-separated file list is invalid syntax -> Option D
  4. Quick Check:

    Multiple files need array syntax [OK]
Quick Trick: Use arrays for multiple files, not commas alone [OK]
Common Mistakes:
  • Using commas without array syntax
  • Thinking pattern must be regex
  • Believing Select-String can't handle multiple files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes