Skip to content

Invoke-SSHCommand hangs and does not return control to the script when the command hangs on the remote side #613

@SeanD-Entara

Description

@SeanD-Entara

I'm pushing out a 'head' command on some remote files via SSH using Invoke-SSHCommand. Once in a while one or two of these files I'm heading will just hang indefinitely on the command. I can actually reproduce that behavior on those particular files manually and that's not the issue. The issue is that even when Invoke-SSHCommand times out, control never returns to my script and everything hangs indefinitely. In fact, I can't even CTRL-C the script and have to close the session entirely.

Error returned:

Exception calling "EndExecute" with "1" argument(s): "Command 'head -n 10 "/path/to/file"' has timed out."
At C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\3.2.4\Posh-SSH.psm1:294 char:25
+                         $Output = $_.cmd.EndExecute($_.Async)
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SshOperationTimeoutException

Wanted to post the issue here before I started trying to muck around in your code in case you have any idea.

Any help is appreciated and also want to add that this is a great module that I get a lot of mileage out of and really appreciate the work.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions