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

[Bug] - `Set-SftpItem` Stops `Enter-PSSession` Due to Progress Stream

Open mattcargile opened this issue 1 year ago • 5 comments

When I run the below type of flow, the powershell ( 5.1.17763.6189 on Microsoft Windows Server 2019 Datacenter ) session is killed with the below. My client is pwsh 7.4.5 though I connect to the Desktop endpoint. My module version is _ 3.1.2_ which is old and I'm just now seeing that.

Processing data from remote server server1 failed with the following error message:
    The WSMan provider host process did not return a proper response.  A provider in the host process may have
    behaved improperly. For more information, see the about_Remote_Troubleshooting Help topic.

I run get-sftpchilditem , I do see the file was partially uploaded.

etsn server1
new-sftpSession -ComputerName IPAddress -Port 22 -Credential user
set-sftpItem -SessionId 0 -Destination /home/user/ -Path .\file.zip

Workaround

Run the below prior to uploading files. So I assume there is something going on with out the progress stream is being written.

$progresspreference = 'SilentlyContinue'

mattcargile avatar Aug 26 '24 17:08 mattcargile

yep

darkoperator avatar Aug 26 '24 17:08 darkoperator

I don't get the wsman error, since this module does not use powershell sessions or CIM. Are you importing the module remotely or using a pssession?

darkoperator avatar Aug 26 '24 17:08 darkoperator

I don't get the wsman error, since this module does not use powershell sessions or CIM. Are you importing the module remotely or using a pssession?

Hmm. I import the module on the remote inside a powershell 5.1 session. Then I connect to another host via New-SftpSession.

Maybe it is a Module version issue on my end. Have you tried a largeish file that would actually show the progress bar? Are you using PowerShell Core as your client too?

mattcargile avatar Aug 26 '24 19:08 mattcargile

I normally install the module on the host I’m running commands at. It could be since I need to use eventing to show progress from the even I have to use the UI in a non standard way and when you import from a remote hosts you are using WSMAN, so everything is serialized as XML sent over WinRM to the host and all objects are serialized that way including the progress information. That may be why if you disable progress you dont get the error, because the rest of the information can be serialized as it is supposed to.

darkoperator avatar Aug 26 '24 23:08 darkoperator

been checking and it could be a memory issue. I would try raising the memory of the PSSession. Can you try raising your max memory and testing?

set-item wsman:localhost\Shell\MaxMemoryPerShellMB 1024

Default is 150mb and the progress information when there are a lot of files could be consuming the amount of memory

https://learn.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management?redirectedfrom=MSDN

darkoperator avatar Aug 31 '24 11:08 darkoperator