powershell

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2021 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExecutorPowerShell ExecutorName = "powershell.exe"
	ExecutorPWSH       ExecutorName = "pwsh.exe"

	// refer: https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/About/about_PowerShell_exe?view=powershell-5.1#-inputformat-text--xml
	IOFormatText IOFormat = "Text"
	IOFormatXML  IOFormat = "XML"

	// refer: https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/About/about_execution_policies?view=powershell-5.1#powershell-execution-policies
	ExecutionPolicyDefault      ExecutionPolicy = "Default"
	ExecutionPolicyAllSigned    ExecutionPolicy = "AllSigned"
	ExecutionPolicyBypass       ExecutionPolicy = "Bypass"
	ExecutionPolicyRemoteSigned ExecutionPolicy = "RemoteSigned"
	ExecutionPolicyRestricted   ExecutionPolicy = "Restricted"
	ExecutionPolicyUndefined    ExecutionPolicy = "Undefined"
	ExecutionPolicyUnrestricted ExecutionPolicy = "Unrestricted"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands struct {
	// contains filtered or unexported fields
}

func (*Commands) Close

func (psc *Commands) Close() error

func (*Commands) Execute

func (psc *Commands) Execute(ctx context.Context, id string, command string) (string, string, error)

Execute allows to input a `command` one by one, returns execution result, stdout info, stderr info and error.

type CreateOptions

type CreateOptions struct {
	Executor          ExecutorName    // executor of PowerShell.
	Sta               bool            // starts PowerShell using a single-threaded apartment.
	NoProfile         bool            // does not load the PowerShell profile.
	InputFormat       IOFormat        // describes the format of data sent to PowerShell.
	OutputFormat      IOFormat        // determines how output from PowerShell is formatted.
	ConfigurationName string          // specifies a configuration endpoint in which PowerShell is run.
	ExecutionPolicy   ExecutionPolicy // sets the default execution policy for the current session and saves it in the `$env:PSExecutionPolicyPreference` environment variable.
}

type ExecutionPolicy

type ExecutionPolicy string

type ExecutorName

type ExecutorName string

type IOFormat

type IOFormat string

type PowerShell

type PowerShell struct {
	// contains filtered or unexported fields
}

func Create

func Create(session *ssh.Session, opts *CreateOptions) *PowerShell

func (*PowerShell) Commands

func (ps *PowerShell) Commands() (*Commands, error)

Commands holds the input of PowerShell.

func (*PowerShell) ExecuteCommand

func (ps *PowerShell) ExecuteCommand(ctx context.Context, id string, stdout, stderr StdStream, command string) error

ExecuteCommand executes the `command`, this method will be blocked until finish or error occur, returns nil when exit code is 0.

func (*PowerShell) ExecuteScript

func (ps *PowerShell) ExecuteScript(ctx context.Context, id string, stdout, stderr StdStream, scriptPath string, scriptArgs ...string) error

ExecuteScript executes the `scriptPath` script with `scriptArgs`, this method will be blocked until finish or error occur, returns nil when exit code is 0

type StdStream

type StdStream func(output interface{})

type WindowStyle

type WindowStyle string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL