# LibTmux\Invoke-TmuxChain

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/InvokeTmuxChainCommand.cs#L7
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-invoke-tmuxchain/

```
Invoke-TmuxChain
    [-Server] <LibTmux.Server>
    [-Command] <LibTmux.TmuxCommand[]>
    [-MaxCommands <System.Int32>]
    [-MaxInputBytes <System.Int64>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
```

Execute an ordered command chain against one server.

Execute an explicit array of native commands in order and return one merged
[`TmuxCommandResult`](/en/csharp/latest/reference/libtmux-tmuxcommandresult/). Native generation and window-placement guards are retained.
An empty server pipeline performs no work. Admission validates the complete
array before confirmation or dispatch.

A failed command stops the remaining chain; earlier mutations remain. The
result is merged stdout/stderr, not one receipt per command. Chains are not
transactions. Cancellation cannot undo a command already sent to tmux.

### Notes

[`Tmux.InvalidChain`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/Invoke-TmuxChain.md#notes) terminates invalid admission. [`Tmux.ChainFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/Invoke-TmuxChain.md#notes) retains the
native failure and server target. [`ErrorAction`](/en/powershell/latest/reference/libtmux-invoke-tmuxchain/#LibTmux%5CInvoke-TmuxChain.parameter.ErrorAction) Continue permits later servers
to run; Stop terminates. [`WhatIf`](/en/powershell/latest/reference/libtmux-invoke-tmuxchain/#LibTmux%5CInvoke-TmuxChain.parameter.WhatIf) dispatches nothing. Do not automatically retry
an uncertain mutation.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Confirmation:** Supports `-WhatIf` and `-Confirm`; confirm impact: Medium.
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Server`: The native server to execute against.
- **Outputs:** `LibTmux.TmuxCommandResult`

Related APIs:

- [Commands and control clients](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/commands.md)

## Examples

Example 1

Print two values in order on a previously selected $server.

[Source example](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/Invoke-TmuxChain.md).

```powershell
$commands = 'first', 'second' | ForEach-Object {
    LibTmux\New-TmuxCommand -Name 'display-message' -Arguments @('-p', $_)
}
$server | LibTmux\Invoke-TmuxChain -Command $commands
```

## Parameters

- `Server` (`LibTmux.Server`): The explicit endpoint that receives the operation.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Command` (`LibTmux.TmuxCommand[]`): A nonempty array of native commands in dispatch order.
  Required. Position 1. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).
- `MaxCommands` (`System.Int32`): Positive admitted command count. Default: 1024.
  Optional. Named parameter. Does not accept pipeline input. Documented default: `1024`. [`ValidateRange(1, 2147483647)`](https://learn.microsoft.com/dotnet/api/system.management.automation.validaterangeattribute?view=powershellsdk-7.4.0).
- `MaxInputBytes` (`System.Int64`): Positive UTF-8 budget for command names and argument text, including one NUL terminator per item. Default: 1048576. This is an argv-text budget, not a process-memory or response budget. Native transport and operating-system limits still apply.
  Optional. Named parameter. Does not accept pipeline input. Documented default: `1048576`. [`ValidateRange(1, 9223372036854776000)`](https://learn.microsoft.com/dotnet/api/system.management.automation.validaterangeattribute?view=powershellsdk-7.4.0).
- `Verbose` (`System.Management.Automation.SwitchParameter`): Display verbose messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `vb`.
- `Debug` (`System.Management.Automation.SwitchParameter`): Display debug messages produced by this command.
  Optional. Named parameter. Switch parameter. Common parameter. Does not accept pipeline input. Aliases: `db`.
- `ErrorAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to non-terminating errors.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ea`.
- `WarningAction` (`System.Management.Automation.ActionPreference`): Choose how this command responds to warning messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wa`.
- `InformationAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles information messages.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `infa`.
- `ProgressAction` (`System.Management.Automation.ActionPreference`): Choose how this command handles progress updates.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `proga`.
- `ErrorVariable` (`System.String`): Store the command's error records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ev`.
- `WarningVariable` (`System.String`): Store the command's warning records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `wv`.
- `InformationVariable` (`System.String`): Store the command's information records in the named variable.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `iv`.
- `OutVariable` (`System.String`): Save output in the named variable while passing it down the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ov`.
- `OutBuffer` (`System.Int32`): Buffer output before passing it to the next pipeline command.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `ob`.
- `PipelineVariable` (`System.String`): Make the most recent output object available through a named variable within the pipeline.
  Optional. Named parameter. Common parameter. Does not accept pipeline input. Aliases: `pv`.
- `WhatIf` (`System.Management.Automation.SwitchParameter`): Show the operation without contacting tmux.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `wi`.
- `Confirm` (`System.Management.Automation.SwitchParameter`): Ask for confirmation before the operation.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `cf`.

## Returns

`LibTmux.TmuxCommandResult`: One native merged result after success.
