New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stop-ScriptSession to remoting module to make it possible to clean up after remote execution #594

AdamNaj opened this Issue Mar 1, 2016 · 1 comment


None yet
2 participants

AdamNaj commented Mar 1, 2016

Running this script in 3.3 would get you in trouble:

#$VerbosePreference = "Continue"

Import-Module -Name SPE -Force
$count = 0
do {
    $session = New-ScriptSession -Username "admin" -Password "b" -ConnectionUri "http://sitecore81/"

    $script1 = {
        [Sitecore.Security.Accounts.User]$user = Get-User -Identity admin

    Invoke-RemoteScript -ScriptBlock $script1 -Session $session
} while($count -lt 100)

As the sessions would pile up in memory after the script would end. Added the ability to dispose of sessions so you can now add Stop-ScriptSession near the end of the script like below to dispose of those sessions:

# ...
    Stop-ScriptSession -Session $session
} while($count -lt 100)

Gitbook needs to be refreshed to reflect the need to dispose of sessions.

@AdamNaj AdamNaj self-assigned this Mar 1, 2016

@AdamNaj AdamNaj added this to the 4.0 milestone Mar 1, 2016

AdamNaj added a commit that referenced this issue Mar 1, 2016


This comment has been minimized.


AdamNaj commented Mar 1, 2016


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment