From e23266a11dfb14283995d7d9be5cbb2e2a8445c1 Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Tue, 9 Jun 2020 05:36:31 -0500 Subject: [PATCH] Changed all the Powershell calls to the "echo" cmdlet to "out-file" to reduce the number of bytes that are written as "echo" uses unicode (by default). --- winrmcp/cp.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winrmcp/cp.go b/winrmcp/cp.go index 2115bcf..aefb415 100644 --- a/winrmcp/cp.go +++ b/winrmcp/cp.go @@ -144,7 +144,7 @@ func restoreContent(client *winrm.Client, fromPath, toPath string) error { $writer.Close() } } else { - echo $null > $dest_file_path + out-file -FilePath $dest_file_path -Encoding utf8 -InputObject $null } `, fromPath, toPath) @@ -213,7 +213,7 @@ func cleanupContent(client *winrm.Client, filePath string) error { } func appendContent(shell *winrm.Shell, filePath, content string) error { - cmd, err := shell.Execute(fmt.Sprintf("echo %s >> \"%s\"", content, filePath)) + cmd, err := shell.Execute(fmt.Sprintf("out-file -FilePath \"%s\" -encoding utf8 -Append -InputObject \"%s\"", content, filePath)) if err != nil { return err