Bird
0
0

What does the automatic variable $_ represent in a PowerShell pipeline?

easy📝 Conceptual Q11 of 15
PowerShell - Variables and Data Types
What does the automatic variable $_ represent in a PowerShell pipeline?
AThe version of PowerShell installed
BThe current object being processed in the pipeline
CThe last error message generated
DThe total number of commands run
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of $_ in pipelines

    $_ is a special variable that holds the current item being processed in a pipeline command.
  2. Step 2: Differentiate from other automatic variables

    $PSVersionTable shows version info, errors use $Error, and command counts are not stored in $_.
  3. Final Answer:

    The current object being processed in the pipeline -> Option B
  4. Quick Check:

    $_ = current pipeline item [OK]
Quick Trick: Remember: $_ always means current pipeline item [OK]
Common Mistakes:
  • Confusing $_ with $PSVersionTable
  • Thinking $_ holds error info
  • Assuming $_ is a global variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes