Closed Dmaddu closed 10 months ago
It's because WinRM is an envelope based protocol, where each message has a size limit (see WinRM config parameter MaxEnvelopeSizekb in https://learn.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management#maxenvelopesizekb, whose default is 150kb).
This project is not made to "upload" commands to the remote machine, projects like https://github.com/jbrekelmans/go-winrm might be better for your use case.
If you want to transfer large files, you need to do it in pieces.
One way to do this is to use a powershell scriptlet that keeps reading stdin and writes to a file, then you can pretty much just io.Copy(cmd.Stdin, src); cmd.Stdin.Close()
. It's not very fast and there are several pitfalls.
WinRM is not a great protocol.
Getting the 413 error with the below command
stdout, stderr, _, err := client.RunWithContextWithString(context.Background(), command, "")
the size of the "command" is ~10MB.