Rickard von Essen 51a9a51699 Update winrm and winrmcp dependencies
Updated winrm and winrmcp dependencies. Relevant unit and acceptance tests passed successfully.

shell.Execute didn't return a Command object.

See f1bcf36a69/winrmcp/cp.go (L167) and 54ea5d0147/winrm/shell.go (L10-L22) respectively.

Closes #3763

Original patch by: Philipp Kosel <philipp.kosel@gmail.com>
2016-10-03 13:48:29 -07:00

24 lines
563 B
Go

package winrm
import (
"encoding/base64"
"fmt"
)
// Powershell wraps a PowerShell script
// and prepares it for execution by the winrm client
func Powershell(psCmd string) string {
// 2 byte chars to make PowerShell happy
wideCmd := ""
for _, b := range []byte(psCmd) {
wideCmd += string(b) + "\x00"
}
// Base64 encode the command
input := []uint8(wideCmd)
encodedCmd := base64.StdEncoding.EncodeToString(input)
// Create the powershell.exe command line to execute the script
return fmt.Sprintf("powershell.exe -EncodedCommand %s", encodedCmd)
}