Bird
0
0

What output will the following PowerShell function produce when piping the numbers 4, 5, and 6?

medium📝 Command Output Q5 of 15
PowerShell - Functions
What output will the following PowerShell function produce when piping the numbers 4, 5, and 6?
function Multiply-ByThree {
  param([Parameter(ValueFromPipeline=$true)]$Number)
  process { $Number * 3 }
}
4,5,6 | Multiply-ByThree
A4 5 6
B12 15 18
C3 3 3
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand pipeline input

    The function accepts pipeline input via the parameter $Number.
  2. Step 2: Process block operation

    Each piped number is multiplied by 3 and output.
  3. Step 3: Calculate outputs

    4*3=12, 5*3=15, 6*3=18.
  4. Final Answer:

    12 15 18 -> Option B
  5. Quick Check:

    Each input multiplied by 3 outputs correctly [OK]
Quick Trick: Process block runs for each pipeline input [OK]
Common Mistakes:
  • Expecting original numbers instead of multiplied values
  • Not recognizing the process block runs per input
  • Assuming no output without explicit Write-Output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes