Skip to content

trobert2/winrm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinRM

This is a Go module for interacting with the Windows Remote Management system (WinRM)

Here is a quick usage example with Basic Authentication:

package main


// We use a forked version of net/http and crypto/tls
// because the standard libs do now support renegotiation

import (
    "fmt"
    "launchpad.net/gwacl/fork/http"
    "github.com/trobert2/winrm"
)


func main(){
    p := winrm.ShellParams{}
    Soap := winrm.SoapRequest{
        Endpoint:"https://192.168.100.154:5986/wsman",
        Username:"Administrator",
        Passwd:"Passw0rd",
        AuthType:"BasicAuth",
        HttpInsecure:true,
        HttpClient: &http.Client{},
    }
    cmdParam := winrm.CmdParams{
        Cmd: "dir",
        Args: "c:\\ /A",
    }

    v := &winrm.Envelope{}
    strdout, stderr, ret_code, _ := v.RunCommand(p, cmdParam, Soap)
    fmt.Printf("Output:%s\nError: %s\nCode:%v\n", strdout, stderr, ret_code)
}

And one with Client side certificates:

package main

// We use a forked version of net/http and crypto/tls
// because the standard libs do now support renegotiation

import (
    "fmt"
    "launchpad.net/gwacl/fork/http"
    "github.com/trobert2/winrm"
)


func main(){
    p := winrm.ShellParams{}
    Soap := winrm.SoapRequest{
        Endpoint:"https://192.168.100.155:5986/wsman",
        AuthType:"CertAuth",
        HttpInsecure:true,
        CertAuth: &winrm.CertificateCredentials{
            Cert: "/home/ubuntu/maas/SSL/certs/testing.pfx.pem",
            Key: "/home/ubuntu/maas/SSL/certs/dec.key",
        },
        HttpClient: &http.Client{},
    }
    cmdParam := winrm.CmdParams{
        Cmd: "dir",
        Args: "c:\\ /A",
    }

    v := &winrm.Envelope{}
    strdout, stderr, ret_code, err := v.RunCommand(p, cmdParam, Soap)
    fmt.Printf("Output:%s\nError: %s\nCode:%v\nERROR:%s\n", strdout, stderr, ret_code, err)
}

About

Winrm module ported using golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages