psdirect

package
v0.1.57 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package psdirect implements vmsdk.GuestExec via PowerShell Direct using the go-psrp library's native PSRP/HvSocket transport. No powershell.exe subprocess is needed — PSRP is spoken in Go directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exec

type Exec struct {
	// VMID is the Hyper-V VM GUID (the resource ID from the hyperv driver).
	VMID string

	// Username and Password are the guest OS credentials for PSRP authentication.
	Username string
	Password string

	// Domain is the guest domain for authentication ("." for local accounts).
	// Defaults to "." if empty.
	Domain string
	// contains filtered or unexported fields
}

Exec implements vmsdk.GuestExec via PowerShell Direct (HvSocket/PSRP). It communicates with the VM guest using the PSRP wire protocol natively — no powershell.exe subprocess is required.

The guest must have PowerShell remoting enabled (enabled by default on Windows Server; run Enable-PSRemoting on Windows 10/11).

func New

func New(vmID, username, password string) *Exec

New returns a PowerShell Direct executor for a VM identified by its GUID.

func (*Exec) Exec

func (e *Exec) Exec(ctx context.Context, cmd string, args ...string) (*vmsdk.ExecResult, error)

Exec runs cmd with args on the Windows guest via PowerShell Direct (HvSocket). Stdout is captured via Out-String; $LASTEXITCODE is returned as the exit code.

func (*Exec) ExecStream added in v0.1.34

func (e *Exec) ExecStream(ctx context.Context, cmd string, args []string, sink eventstream.Sink) (*vmsdk.ExecResult, error)

ExecStream runs cmd through PowerShell Direct and forwards PSRP output as it arrives. PowerShell's merged native output is represented on stdout; PSRP error, warning, verbose, debug, progress, and information records are all merged onto stderr — none of those are exclusively "errors", so a caller deciding whether a command failed should rely on the exit code, not on whether anything arrived on the stderr channel.

Jump to

Keyboard shortcuts

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