modulepackage
0.1.0
Repository: https://github.com/hnakamur/go-powershell.git
Documentation: pkg.go.dev
# README
go-powershell
go-powershell is a Go library to execute commands on a local PowerShell session.
This is a slimed down rewrite of github.com/bhendo/go-powershell which is a fork of github.com/gorillalabs/go-powershell.
The API is not compatible with github.com/bhendo/go-powershell
The original package was inspired by jPowerShell and allows one to run and remote-control a PowerShell session. Use this if you don't have a static script that you want to execute, bur rather run dynamic commands.
Usage
package main
import (
"fmt"
"log"
"github.com/hnakamur/go-powershell"
)
func main() {
shell, err := powershell.New()
if err != nil {
log.Fatal(err)
}
defer shell.Exit()
stdout, err := shell.Exec("echo こんにちは")
if err != nil {
log.Fatal(err)
}
fmt.Println(stdout)
stdout, err = shell.Exec("Get-TimeZone | Select-Object StandardName")
if err != nil {
log.Fatal(err)
}
fmt.Println(stdout)
}
License
MIT, see LICENSE file.
# Functions
New creates a new PowerShell session.
# Variables
Encodings contains a mapping from code page to encoding.
ErrUnsupportedCodePage is the error returned from the New method if the detected code page is not in the Encodings map.