0
0
PowerShellscripting~20 mins

Process management (Get/Stop-Process) in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Process Management Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this PowerShell command?
Consider the following command run on a system with multiple running processes named 'notepad':

Get-Process -Name notepad | Select-Object -First 1 | Format-Table -Property Id, ProcessName -HideTableHeaders

What will this command output?
PowerShell
Get-Process -Name notepad | Select-Object -First 1 | Format-Table -Property Id, ProcessName -HideTableHeaders
ADisplays all 'notepad' processes with Id and ProcessName including headers
BDisplays the Id and ProcessName of the first 'notepad' process found, without table headers
CThrows an error because Format-Table cannot be used with Select-Object
DDisplays only the ProcessName of all 'notepad' processes
Attempts:
2 left
💡 Hint
Think about how Select-Object and Format-Table work together and what -HideTableHeaders does.
📝 Syntax
intermediate
1:30remaining
Which command correctly stops all running 'calc' processes?
You want to stop all processes named 'calc' using PowerShell. Which of the following commands will do this correctly?
AStop-Process -ProcessName calc
BStop-Process calc
CStop-Process -Id calc
DStop-Process -Name calc
Attempts:
2 left
💡 Hint
Check the parameter names for Stop-Process.
🔧 Debug
advanced
2:00remaining
Why does this script fail to stop the process?
You run this script to stop a process named 'example':

$proc = Get-Process example
Stop-Process $proc


But it throws an error. What is the cause?
AStop-Process expects process Id or name, not a process object
BYou need to convert $proc to string before passing
CStop-Process requires the -Name parameter explicitly
DGet-Process did not find any process named 'example'
Attempts:
2 left
💡 Hint
Check what type of input Stop-Process accepts.
🚀 Application
advanced
2:30remaining
How to safely stop a process only if it is running?
You want to stop a process named 'myapp' only if it is currently running, without causing errors if it is not. Which script snippet achieves this?
AGet-Process -Name myapp | Stop-Process
BStop-Process -Name myapp -ErrorAction SilentlyContinue
Cif (Get-Process -Name myapp -ErrorAction SilentlyContinue) { Stop-Process -Name myapp }
DStop-Process -Name myapp -Force
Attempts:
2 left
💡 Hint
Think about checking existence before stopping.
🧠 Conceptual
expert
1:30remaining
What is the effect of using Stop-Process with the -Force parameter?
In PowerShell, what does the -Force parameter do when used with Stop-Process?
AIt forces the process to stop immediately, ignoring any prompts or errors
BIt only stops processes running with administrator privileges
CIt delays stopping the process until all child processes are stopped
DIt logs the stop action but does not actually stop the process
Attempts:
2 left
💡 Hint
Consider what 'force' usually means in commands.