Posh-SSH icon indicating copy to clipboard operation
Posh-SSH copied to clipboard

Smarter Invoke-SSHCommandExpectSecureAction and Invoke-SSHCommandExpectAction

Open Viajaz opened this issue 4 years ago • 1 comments

Cmdlets like Invoke-SSHStreamShellCommand appear to return a String of the StdOut of their calls, despite documentation saying otherwise, it would be useful if Cmdlets like Invoke-SSHCommandExpectSecureAction and Invoke-SSHCommandExpectAction could do the same instead of us having to write boilerplate code to build a string from the Stream such as:

$OutputBuilder = [System.Text.StringBuilder]::new()
do {
    $ReadOutput = $SshStream.Read()
    $OutputBuilder.Append($ReadOutput) | Out-Null
} while($SshStream.DataAvailable)
return $OutputBuilder.ToString()

Viajaz avatar Dec 08 '21 01:12 Viajaz

That womb be a change in behavior so would have to wait for.a major release. The logic as I wrote it (remember this is a hobby project for my use at work that I share out so it is mainly designed around my personal scenarios) is for sudo prompts or stuff that stops execution and needs some action, that way I can take care of it, pass more commands and then read the stream once all of my commands are done, if not I can quickly just read the stream and continue. Still thanks for the feedback, may make it as a param that can be given.

On Dec 7, 2021, at 9:52 PM, Viajaz @.***> wrote:

Cmdlets like Invoke-SSHStreamShellCommand appear to return a String of the StdOut of their calls, despite documentation saying otherwise, it would be useful if Cmdlets like Invoke-SSHCommandExpectSecureAction and Invoke-SSHCommandExpectAction could do the same instead of us having to write boilerplate code to build a string from the Stream such as:

$OutputBuilder = [System.Text.StringBuilder]::new() do { $ReadOutput = $SshStream.Read() $OutputBuilder.Append($ReadOutput) | Out-Null } while($SshStream.DataAvailable) return $OutputBuilder.ToString() — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/darkoperator/Posh-SSH/issues/435, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7IHSDKZVEXPPM3R5655DUP227VANCNFSM5JSUO3PQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

darkoperator avatar Dec 08 '21 16:12 darkoperator