Wait-Process
Use Wait-Process to block until one or more processes exit, or until a timeout expires.
Documentation: Microsoft Learn — Wait-Process
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Wait-Process [-Name] <String[]> [[-Timeout] <int32>] [<CommonParameters>]- Stage 1Wait-Process
-Name -Timeout
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Wait-Process -Name notepad
Show reference output
Sample output · fictional data, shaped like the real thing
(No pipeline output. The selected process exited before the timeout.)
Wait-Process -Id $p.Id
Show reference output
Sample output · fictional data, shaped like the real thing
Handles NPM(K) PM(M) WS(M) CPU(s) Id ProcessName ------- ------ ----- ----- ------ -- ----------- 86 12 18.4 27.2 0.08 7344 notepad
Stop-Service -Name MyApp
Show reference output
Sample output · fictional data, shaped like the real thing
(No pipeline output. The selected process exited before the timeout.)
Parameters
Parameter definitions:
-Name-Timeout
Practical use and troubleshooting
Practical scenario: Use Wait-Process when you need to block until one or more processes exit, or until a timeout expires. Review syntax and sample output, then try an example in the browser lab. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: A timeout means the process has not exited within the allowed interval. Report that condition explicitly and decide whether to keep waiting; do not interpret a timeout as successful completion. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Stop-Process. Stop-Process requests process termination; Wait-Process waits for a process to exit. Waiting does not stop the application and termination is not a graceful application shutdown. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Recap
Wait-Process Use Wait-Process to block until one or more processes exit, or until a timeout expires.
Next: Get-Process