PowerShell Genie

Stop-Process

Use Stop-Process to stop running processes by name or ID; -Force ends processes that ignore a normal stop request.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Stop-Process

Syntax

1PS> Stop-Process [-Id] <Int32[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
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.

Stop-Process [-Id] <Int32[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
  1. Stage 1Stop-Process-Id -PassThru -Force -WhatIf -Confirm

    Try it

    Windows PowerShell

    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.

    Interactive simulation · fictional data

    Examples

    Get-Process -Name notepad

    1PS> Get-Process -Name notepad | Stop-Process
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Get-Process: Cannot find a process with the name "notepad". Verify the process name and call the cmdlet again.

    Stop-Process -Id 4242

    1PS> Stop-Process -Id 4242
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Stop-Process: Cannot find a process with the process identifier 4242. Verify the process identifier and call the cmdlet again.

    Get-Process -Name notepad (2)

    1PS> Get-Process -Name notepad | ForEach-Object { $_.CloseMainWindow() }
    Show reference output

    Sample output · fictional data, shaped like the real thing

    True

    Parameters

    Parameter definitions:

    • -Id
    • -PassThru
    • -Force
    • -WhatIf
    • -Confirm

    Stop-Process on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Stop-Process when you need to stop running processes by name or ID; -Force ends processes that ignore a normal stop request. 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: Access denied when terminating another user's process may require elevation. Confirm its current process ID and owner first; a recycled process ID can identify a different application later. 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: Wait-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.

    Stop-Process reference on Microsoft Learn

    Recap

    Stop-Process Use Stop-Process to stop running processes by name or ID; -Force ends processes that ignore a normal stop request.

    Next: Get-Process
    Genie guideStop-Process

    Use Stop-Process to stop running processes by name or ID; -Force ends processes that ignore a normal stop request. The console below is pre-loaded — run it, then change a value and run it again.