commands

^

Stop-DbaExternalProcess

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Stop-DbaExternalProcess on GitHub.
Want to see the Bill Of Health for this command? Check out Stop-DbaExternalProcess.

Synopsis

Stops an OS process created by SQL Server

Description

Stops an OS process created by SQL Server

Helps when killing hung sessions with External Wait Types

https://web.archive.org/web/20201027122300/http://vickyharp.com/2013/12/killing-sessions-with-external-wait-types/

Syntax

Stop-DbaExternalProcess
    [-ComputerName] <DbaInstanceParameter>
    [[-Credential] <PSCredential>]
    [[-ProcessId] <Int32>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaExternalProcess -ComputerName SQL01 | Stop-DbaExternalProcess

Kills all OS processes created by SQL Server on SQL01

Example: 2
PS C:\> Get-DbaExternalProcess -ComputerName SQL01 | Where-Object Name -eq "cmd.exe" | Stop-DbaExternalProcess

Kills all cmd.exe processes created by SQL Server on SQL01

Required Parameters

-ComputerName

The target SQL Server host computer

Alias
Required True
Pipeline true (ByPropertyName)
Default Value

Optional Parameters

-Credential

Allows you to login to $ComputerName using alternative credentials.

Alias
Required False
Pipeline true (ByPropertyName)
Default Value
-ProcessId

The process ID of the OS process to kill

Alias pid
Required False
Pipeline true (ByPropertyName)
Default Value 0
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value