Bird
0
0

What will be the output of this PowerShell command?

medium📝 Command Output Q13 of 15
PowerShell - System Administration
What will be the output of this PowerShell command?
Get-Process -Name powershell | Stop-Process -PassThru
ALists all running PowerShell processes without stopping them
BStops the PowerShell process and outputs the stopped process details
CThrows an error because Stop-Process cannot be piped
DStarts a new PowerShell process
Step-by-Step Solution
Solution:
  1. Step 1: Understand the pipeline usage

    The command gets the process named 'powershell' and pipes it to Stop-Process. The -PassThru parameter makes Stop-Process output the stopped process object.
  2. Step 2: Predict command behavior

    The process will be stopped, and its details will be shown as output. No error occurs because piping is supported.
  3. Final Answer:

    Stops the PowerShell process and outputs the stopped process details -> Option B
  4. Quick Check:

    Get-Process piped to Stop-Process with -PassThru stops and outputs = B [OK]
Quick Trick: Stop-Process supports pipeline input and -PassThru outputs stopped process [OK]
Common Mistakes:
  • Thinking Stop-Process cannot accept pipeline input
  • Assuming it only lists processes without stopping
  • Confusing -PassThru as a force stop

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes