Skip to content

Remoting: Wait-RemoteScriptSession throws exception when remote script is done #966

@GlennvG

Description

@GlennvG

When using Wait-RemoteScriptSession it is polling the remote script every 5 seconds. But when the remote script is finished it throws an error that the script session cannot be found.

Code:

Wait-RemoteScriptSession -Session $session -Id $jobId -Delay 5 -Verbose

Logging:

2017-12-19T12:48:06.5154815Z VERBOSE: Polling job b7668a0c-421a-4703-b94a-e111af7e30c7. Status : Busy.
2017-12-19T12:48:11.5207123Z VERBOSE: Checking the Runspace for the variable id.
2017-12-19T12:49:20.6055452Z ##[error]The script session with Id 'b7668a0c-421a-4703-b94a-e111af7e30c7' cannot be found.
2017-12-19T12:49:20.6057975Z VERBOSE: Polling job . Status : .
2017-12-19T12:49:20.6059073Z VERBOSE: Finished polling job b7668a0c-421a-4703-b94a-e111af7e30c7.
2017-12-19T12:49:20.6061579Z VERBOSE: Checking the Runspace for the variable id.
2017-12-19T12:49:20.9194256Z Get-ScriptSession : The script session with Id 'b7668a0c-421a-4703-b94a-e111af7e30c7' cannot be found.
2017-12-19T12:49:20.9195444Z At line:2 char:36
2017-12-19T12:49:20.9195935Z + $backgroundScriptSession = Get-ScriptSession -Id $params.__using_id
2017-12-19T12:49:20.9196430Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-12-19T12:49:20.9196997Z + CategoryInfo : ResourceUnavailable: (b7668a0c-421a-4703-b94a-e111af7e30c7:String) [Get-ScriptSession],
2017-12-19T12:49:20.9197511Z ObjectNotFoundException
2017-12-19T12:49:20.9198138Z + FullyQualifiedErrorId : ScriptSessionNotFound,Cognifide.PowerShell.Commandlets.ScriptSessions.GetScriptSessionCo
2017-12-19T12:49:20.9198805Z mmand

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions