# Stop-ScriptSession

Stops executing script session.

## Syntax

Stop-ScriptSession -Id \<String\[]>

Stop-ScriptSession -Session \<ScriptSession\[]>

## Detailed Description

Aborts the pipeline of a session that is executing. This will stop the session immediately in its next PowerShell command. Caution! If your script is running a long operation in the .net code rather than in PowerShell - the session will abort after the code has finished and the control was returned to the script.

© 2010-2019 Adam Najmanowicz, Michael West. All rights reserved. Sitecore PowerShell Extensions

## Parameters

### -Id \<String\[]>

Stops the script session with the specified IDs. The ID is a string that uniquely identifies the script session within the server. You can type one or more IDs (separated by commas). To find the ID of a script session, type "Get-ScriptSession" without parameters.

| Aliases                     |                |
| --------------------------- | -------------- |
| Required?                   | true           |
| Position?                   | named          |
| Default Value               |                |
| Accept Pipeline Input?      | true (ByValue) |
| Accept Wildcard Characters? | false          |

### -Session \<ScriptSession\[]>

Specifies the script session to be stopped. Enter a variable that contains the script session or a command that gets the script session. You can also pipe a script session object to Receive-ScriptSession.

| Aliases                     |                |
| --------------------------- | -------------- |
| Required?                   | true           |
| Position?                   | named          |
| Default Value               |                |
| Accept Pipeline Input?      | true (ByValue) |
| Accept Wildcard Characters? | false          |

## Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

* System.String or Spe.Core.Host.ScriptSession

## Outputs

The output type is the type of the objects that the cmdlet emits.

* Spe.Core.Host.ScriptSession

## Notes

Help Author: Adam Najmanowicz, Michael West

## Examples

### EXAMPLE

```powershell
The following stops the script session with the specified Id.

PS master:\> Stop-ScriptSession -Id "My Background Script Session"
```

## Related Topics

* [Get-ScriptSession](/appendix/session/get-scriptsession.md)
* [Receive-ScriptSession](/appendix/session/receive-scriptsession.md)
* [Remove-ScriptSession](/appendix/session/remove-scriptsession.md)
* [Start-ScriptSession](/appendix/session/start-scriptsession.md)
* [Wait-ScriptSession](/appendix/session/wait-scriptsession.md)
* <https://blog.najmanowicz.com/2014/10/26/sitecore-powershell-extensions-persistent-sessions/>
* <https://git.io/spe>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.sitecorepowershell.com/appendix/session/stop-scriptsession.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
