Bird
0
0

Why is $_ considered an automatic variable in PowerShell pipelines?

hard📝 Conceptual Q10 of 15
PowerShell - Variables and Data Types
Why is $_ considered an automatic variable in PowerShell pipelines?
ABecause it automatically holds the current pipeline object during iteration.
BBecause it stores the PowerShell version automatically.
CBecause it automatically saves the last command's output.
DBecause it automatically contains user environment variables.
Step-by-Step Solution
Solution:
  1. Step 1: Define automatic variable behavior

    Automatic variables are predefined and updated by PowerShell during execution.
  2. Step 2: Explain $_ role

    $_ automatically holds the current object in the pipeline for each iteration, enabling easy access.
  3. Final Answer:

    Because it automatically holds the current pipeline object during iteration. -> Option A
  4. Quick Check:

    $_ = current pipeline object automatically [OK]
Quick Trick: $_ auto-updates with current pipeline item [OK]
Common Mistakes:
  • Confusing $_ with version or output variables
  • Thinking $_ stores environment variables
  • Assuming $_ is user-defined

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes