func (this Scanner) executeCommand(cmd string, shell *winrm.Shell) (string, error) {
	command, err := shell.Execute(cmd)
	if err != nil {
		return "", err
	}
	var outWriter, errWriter bytes.Buffer
	var wg sync.WaitGroup
	wg.Add(2)
	go func() {
		defer wg.Done()
		io.Copy(&outWriter, command.Stdout)
	}()
	go func() {
		defer wg.Done()
		io.Copy(&errWriter, command.Stderr)
	}()
	command.Wait()
	wg.Wait()
	output := outWriter.String() + errWriter.String()
	return output, err
}
Executes a command on a winrm client connection, returns an error if there is one
package winrm
import (
	"bytes"
	"io"
	"strconv"
	"strings"
	"sync"
	"github.com/emperorcow/go-netscan/scanners"
	"github.com/masterzen/winrm"
)
type Scanner struct{}
func (this Scanner) Name() string {
	return "winrm"
}
func (this Scanner) Description() string {
	return "Windows Remote Managment (WinRM)"
}
func (this Scanner) SupportedAuthentication() []string {
	return []string{"basic"}
}
func (this Scanner) SupportedAuthenticationExample() map[string]string {
	return map[string]string{
		"basic": "USERNAME,PASSWORD",
	}
}
func (this Scanner) Scan(target, exec string, cred scanners.Credential, out chan scanners.Result) {
	if !strings.Contains(target, ":") {
		target = target + ":5985"
	}
	var err error
	var client *winrm.Client
	switch cred.Type {
	case "basic":
		client, err = this.basicConnect(cred.Account, target, cred.AuthData)
	}
	result := scanners.Result{
		Host:    target,
		Auth:    cred,
		Message: "Succesfully connected",
		Status:  true,
		Output:  "",
	}
	shell, err := client.CreateShell()
	if err != nil {
		result.Message = err.Error()
		result.Status = false
	} else {
		defer shell.Close()  
	}
	if err == nil && exec != "" {
		result.Output, err = this.executeCommand(exec, shell)
		if err != nil {
			result.Output = "Script Error: " + err.Error()
		}
	}
	out <- result
}