winrm

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package winrm provides functionality for establishing and managing WinRM (Windows Remote Management) connections. It facilitates executing commands on remote Windows machines securely over HTTP(S) using the WinRM protocol.

Key Features:

  • Establishes WinRM connections based on provided configuration.
  • Handles authentication and secure communication with remote Windows hosts.
  • Supports execution of commands including cmd and powershell commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Username string
	Password string
	Host     string
	Port     int
	UseTLS   bool
	Insecure bool
	Timeout  time.Duration
}

Config represents the configuration details for establishing a WinRM connection.

type Connection

type Connection struct {
	Client *winrm.Client
}

Connection represents a WinRM connection.

func NewConnection

func NewConnection(config *Config) (*Connection, error)

NewConnection creates a new WinRM client based on the provided WinRM configuration.

func (*Connection) Close

func (c *Connection) Close() error

Close closes the WinRM connection. Satisfies the Connection interface.

func (*Connection) Run

Run runs a command using the configured WinRM connection and context. It returns a connection.CMDResult object, including stdout and stderr.

func (*Connection) RunWithPowershell

func (c *Connection) RunWithPowershell(ctx context.Context, cmd string) (connection.CmdResult, error)

RunWithPowershell runs a command using the configured WinRM connection and context via Powershell. It returns the result of the command execution, including stdout and stderr.

Jump to

Keyboard shortcuts

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