Skip to content

oko/powershellexec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

powershellexec

This package provides an interface for executing Powershell commands from Go code.

Usage

Run a simple Powershell command:

package main

import (
	"github.com/oko/powershellexec"
	"log"
)

func main() {
	exe := &powershellexec.WrappedExecutor{}
	_, _, err := exe.Execute("whoami")
	if err != nil {
		log.Fatalf("failed to run `whoami` in Powershell: %s", err)
	}
}

If your command will return unusual exit codes (i.e., robocopy calls):

exe.SetExitCodes([]int{1,2,3})

The array of exit codes passed will be checked at command completion.

About

Powershell command execution for Go programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages