51a9a51699
Updated winrm and winrmcp dependencies. Relevant unit and acceptance tests passed successfully. shell.Execute didn't return a Command object. Seef1bcf36a69/winrmcp/cp.go (L167)
and54ea5d0147/winrm/shell.go (L10-L22)
respectively. Closes #3763 Original patch by: Philipp Kosel <philipp.kosel@gmail.com>
24 lines
563 B
Go
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)
|
|
}
|