Skip to main content

Invoke-KeldorCommand

SYNOPSIS

Executes PowerShell code locally or through an explicit remoting transport.

SYNTAX

WsManScriptBlock (Default)

Invoke-KeldorCommand [-ComputerName] <String[]> -ScriptBlock <ScriptBlock> [-ArgumentList <Object[]>]
[-Credential <PSCredential>] [-Authentication <AuthenticationMechanism>] [-Port <Int32>] [-UseSSL]
[-ConfigurationName <String>] [-SessionOption <PSSessionOption>] [-ThrottleLimit <Int32>]
[-TimeoutSec <Int32>] [-RetryCount <Int32>] [-RetryDelaySec <Int32>] [-RawOutput]
[<CommonParameters>]

LocalKeldorCommand

Invoke-KeldorCommand [-Local] -KeldorCommand <String> [-Parameter <Hashtable>] [-ThrottleLimit <Int32>]
[-TimeoutSec <Int32>] [-RetryCount <Int32>] [-RetryDelaySec <Int32>] [-RawOutput]
[<CommonParameters>]

LocalScriptBlock

Invoke-KeldorCommand [-Local] -ScriptBlock <ScriptBlock> [-ArgumentList <Object[]>] [-ThrottleLimit <Int32>]
[-TimeoutSec <Int32>] [-RetryCount <Int32>] [-RetryDelaySec <Int32>] [-RawOutput]
[<CommonParameters>]

SessionKeldorCommand

Invoke-KeldorCommand -Session <PSSession[]> -KeldorCommand <String> [-Parameter <Hashtable>]
[-ThrottleLimit <Int32>] [-TimeoutSec <Int32>] [-RetryCount <Int32>] [-RetryDelaySec <Int32>] [-RawOutput]
[<CommonParameters>]

SessionScriptBlock

Invoke-KeldorCommand -Session <PSSession[]> -ScriptBlock <ScriptBlock> [-ArgumentList <Object[]>]
[-ThrottleLimit <Int32>] [-TimeoutSec <Int32>] [-RetryCount <Int32>] [-RetryDelaySec <Int32>] [-RawOutput]
[<CommonParameters>]

WsManKeldorCommand

Invoke-KeldorCommand [-ComputerName] <String[]> -KeldorCommand <String> [-Parameter <Hashtable>]
[-Credential <PSCredential>] [-Authentication <AuthenticationMechanism>] [-Port <Int32>] [-UseSSL]
[-ConfigurationName <String>] [-SessionOption <PSSessionOption>] [-ThrottleLimit <Int32>]
[-TimeoutSec <Int32>] [-RetryCount <Int32>] [-RetryDelaySec <Int32>] [-RawOutput]
[<CommonParameters>]

SshKeldorCommand

Invoke-KeldorCommand -HostName <String[]> -KeldorCommand <String> [-Parameter <Hashtable>] [-Port <Int32>]
[-UserName <String>] [-KeyFilePath <String>] [-Subsystem <String>] [-ConnectingTimeout <Int32>]
[-SSHTransport] [-ThrottleLimit <Int32>] [-TimeoutSec <Int32>] [-RetryCount <Int32>] [-RetryDelaySec <Int32>]
[-RawOutput] [<CommonParameters>]

SshScriptBlock

Invoke-KeldorCommand -HostName <String[]> -ScriptBlock <ScriptBlock> [-ArgumentList <Object[]>] [-Port <Int32>]
[-UserName <String>] [-KeyFilePath <String>] [-Subsystem <String>] [-ConnectingTimeout <Int32>]
[-SSHTransport] [-ThrottleLimit <Int32>] [-TimeoutSec <Int32>] [-RetryCount <Int32>] [-RetryDelaySec <Int32>]
[-RawOutput] [<CommonParameters>]

DESCRIPTION

Provides Keldor's canonical orchestration entry point for local execution, caller-owned PSSession reuse, WSMan targets, and PowerShell remoting over SSH. By default, it returns one Keldor.CommandExecutionResult per target. Exact duplicate targets are preserved in input order.

Script blocks and arguments are forwarded as objects. Remote output follows normal PowerShell remoting serialization rules and may contain deserialized objects without their original methods. The KeldorCommand mode imports Keldor on the target, resolves only a command from that module, and invokes it with object-based parameter splatting. Keldor is not installed or copied to the target automatically.

TimeoutSec applies to each remote attempt. Local execution remains in-process and cannot be cancelled safely on Windows PowerShell 5.1, so TimeoutSec is recorded but not enforced for Local targets. RetryCount applies only to failures classified as transient connection or transport failures. Caller-supplied sessions are never removed, reconfigured, reconnected, or disposed.

This command does not support ShouldProcess because it cannot determine whether caller-supplied code changes state. WhatIf and Confirm behavior belongs to an invoked command that implements ShouldProcess.

EXAMPLES

EXAMPLE 1

Invoke-KeldorCommand -Local -ScriptBlock { Get-KeldorSystemInfo }

Executes a script block locally and returns a structured execution result.

EXAMPLE 2

Invoke-KeldorCommand -ComputerName 'server01', 'server02' -ScriptBlock { hostname }

Executes through WSMan for multiple targets.

EXAMPLE 3

'server01', 'server02' | Invoke-KeldorCommand -ScriptBlock { Get-Date }

Buffers pipeline targets and executes them as WSMan targets.

EXAMPLE 4

$sessions = Get-PSSession
Invoke-KeldorCommand -Session $sessions -ScriptBlock { Get-KeldorSystemInfo }

Reuses caller-owned sessions. Sessions can also be passed directly with -Session $sessions.

EXAMPLE 5

Invoke-KeldorCommand -HostName 'linux01.example.com' -UserName 'automation' `
-KeyFilePath $keyPath -ScriptBlock { $PSVersionTable }

Executes through PowerShell remoting over SSH on a supported PowerShell runtime.

EXAMPLE 6

Invoke-KeldorCommand -ComputerName 'server01' -KeldorCommand 'Get-KeldorSystemInfo'

Imports Keldor on the target and invokes an installed Keldor command.

EXAMPLE 7

Invoke-KeldorCommand -Local -KeldorCommand 'Get-KeldorOperatingSystem' -Parameter @{}

Invokes a validated local Keldor command with named parameters.

EXAMPLE 8

Invoke-KeldorCommand -ComputerName 'server01' -ScriptBlock { Get-Service } -RawOutput

Writes remoting output directly without Keldor result envelopes.

EXAMPLE 9

Invoke-KeldorCommand -ComputerName 'server01' -ScriptBlock { Get-Date } `
-TimeoutSec 30 -RetryCount 1 -RetryDelaySec 2

Applies a per-attempt timeout and one connection-only retry.

PARAMETERS

-Local

Selects in-process execution on the current computer without creating a remoting session.

Type: SwitchParameter
Parameter Sets: LocalKeldorCommand, LocalScriptBlock
Aliases:

Required: True
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Session

Specifies caller-owned PSSession objects to reuse. Unavailable sessions produce per-target failure results.

Type: PSSession[]
Parameter Sets: SessionKeldorCommand, SessionScriptBlock
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-ComputerName

Specifies WSMan targets. Values may be supplied through the pipeline and are buffered for orchestration.

Type: String[]
Parameter Sets: WsManScriptBlock, WsManKeldorCommand
Aliases: DnsHostName

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-HostName

Specifies SSH remoting targets. SSH remoting requires PowerShell 7.4 or later.

Type: String[]
Parameter Sets: SshKeldorCommand, SshScriptBlock
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-ScriptBlock

Specifies PowerShell code to execute. Keldor does not parse, rewrite, or stringify the script block.

Type: ScriptBlock
Parameter Sets: WsManScriptBlock, LocalScriptBlock, SessionScriptBlock, SshScriptBlock
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ArgumentList

Specifies objects forwarded positionally to ScriptBlock.

Type: Object[]
Parameter Sets: WsManScriptBlock, LocalScriptBlock, SessionScriptBlock, SshScriptBlock
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-KeldorCommand

Specifies an installed Keldor command name to resolve and invoke on the selected target.

Type: String
Parameter Sets: LocalKeldorCommand, SessionKeldorCommand, WsManKeldorCommand, SshKeldorCommand
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Parameter

Specifies named parameter values forwarded as objects to KeldorCommand.

Type: Hashtable
Parameter Sets: LocalKeldorCommand, SessionKeldorCommand, WsManKeldorCommand, SshKeldorCommand
Aliases:

Required: False
Position: Named
Default value: @{}
Accept pipeline input: False
Accept wildcard characters: False

-Credential

Specifies a PSCredential for WSMan. Credential contents are never logged or returned.

Type: PSCredential
Parameter Sets: WsManScriptBlock, WsManKeldorCommand
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Authentication

Specifies the native WSMan authentication mechanism. Keldor does not enable or reconfigure authentication.

Type: AuthenticationMechanism
Parameter Sets: WsManScriptBlock, WsManKeldorCommand
Aliases:
Accepted values: Default, Basic, Negotiate, NegotiateWithImplicitCredential, Credssp, Digest, Kerberos

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Port

Specifies the WSMan or SSH port passed to Invoke-Command.

Type: Int32
Parameter Sets: WsManScriptBlock, WsManKeldorCommand, SshKeldorCommand, SshScriptBlock
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-UseSSL

Uses WSMan over HTTPS. Keldor does not install certificates or disable certificate validation.

Type: SwitchParameter
Parameter Sets: WsManScriptBlock, WsManKeldorCommand
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ConfigurationName

Specifies an existing WSMan endpoint configuration.

Type: String
Parameter Sets: WsManScriptBlock, WsManKeldorCommand
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SessionOption

Specifies an existing WSMan PSSessionOption. Keldor does not mutate the object.

Type: PSSessionOption
Parameter Sets: WsManScriptBlock, WsManKeldorCommand
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-UserName

Specifies the SSH user name.

Type: String
Parameter Sets: SshKeldorCommand, SshScriptBlock
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-KeyFilePath

Specifies an SSH private-key path. Keldor does not read or return key contents.

Type: String
Parameter Sets: SshKeldorCommand, SshScriptBlock
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Subsystem

Specifies the SSH subsystem passed to Invoke-Command.

Type: String
Parameter Sets: SshKeldorCommand, SshScriptBlock
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ConnectingTimeout

Specifies the native SSH connection timeout in milliseconds.

Type: Int32
Parameter Sets: SshKeldorCommand, SshScriptBlock
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-SSHTransport

Explicitly selects the native SSH transport switch for HostName execution.

Type: SwitchParameter
Parameter Sets: SshKeldorCommand, SshScriptBlock
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ThrottleLimit

Specifies the conservative maximum target concurrency. The initial implementation uses bounded target batches.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 32
Accept pipeline input: False
Accept wildcard characters: False

-TimeoutSec

Specifies the maximum elapsed seconds for each remote target attempt. Zero disables the Keldor timeout.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-RetryCount

Specifies additional connection-only attempts after the initial attempt. The default is zero.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False

-RetryDelaySec

Specifies the delay in seconds between eligible connection retries.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False

-RawOutput

Writes command output directly and writes normalized failures to the error stream instead of returning result envelopes. Per-target Keldor metadata is unavailable, but native remoting metadata remains when present.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String and System.Management.Automation.Runspaces.PSSession.

OUTPUTS

Keldor.CommandExecutionResult, or unwrapped command output when RawOutput is used.

NOTES

ComputerName selects WSMan, HostName selects SSH, Session reuses its existing transport, and Local uses no remoting transport. Keldor does not probe or fall back between transports and does not require ICMP.

ALIASES

None.

PLATFORM APPLICABILITY

Windows, macOS, and Linux.

POWERSHELL COMPATIBILITY

See PowerShell compatibility for the supported runtime policy. PowerShell 7.6 LTS is preferred.

https://docs.keldor.dev/powershell/keldor/Invoke-KeldorCommand