# LibTmux\Invoke-TmuxCommand

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

```
Invoke-TmuxCommand
    [-Server] <LibTmux.Server>
    [-Arguments] <System.String[]>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
```

Execute literal tmux arguments against an explicit server.

Pass the tmux command name and arguments as a string array. The adapter invokes the core directly without a shell. It returns a native [`TmuxCommandResult`](/en/csharp/latest/reference/libtmux-tmuxcommandresult/) only on success; a nonzero exit writes an error retaining the result, target and dispatch metadata.

Literal commands that an optional feature cannot run safely on the daemon's tmux release are refused before the requested command is dispatched. Version checks may still contact tmux. A command that needs another release raises LibTmux.TmuxVersionTooLowException. A session or window name that exactly tmux 3.7 rejects, and a layout string that tmux before 3.4 crashes on, raise LibTmux.TmuxUnsupportedOnReleaseException, the type that TmuxVersionTooLowException derives from, so one catch of it covers every refusal. Only the command given is checked. A refused command carried inside another command's text is not: an [if-shell](/en/tmux/latest/manual/if-shell/) or [run-shell](/en/tmux/latest/manual/run-shell/) -C string, [bind-key](/en/tmux/latest/manual/bind-key/), [set-hook](/en/tmux/latest/manual/set-hook/), [confirm-before](/en/tmux/latest/manual/confirm-before/), a menu, a prompt or choose template, or a brace block. Nested, it reaches tmux unchanged. A nameless [break-pane](/en/tmux/latest/manual/break-pane/) ends a tmux 3.7 server, so on exactly 3.7 name every [break-pane](/en/tmux/latest/manual/break-pane/), including the one prefix ! runs, or upgrade to 3.7a. The other failures are listed at https://libtmux.org/en/powershell/latest/guides/compatibility/#what-the-checks-do-not-read

### Notes

Arguments can mutate tmux or run application commands. [`WhatIf`](/en/powershell/latest/reference/libtmux-invoke-tmuxcommand/#LibTmux%5CInvoke-TmuxCommand.parameter.WhatIf) performs no dispatch. Confirmation shows the command name without exposing the full argument content. Cancellation does not prove a dispatched mutation was rolled back; do not retry uncertain mutations automatically.

## 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`: Native pipeline type for this command.
- **Outputs:** `LibTmux.TmuxCommandResult`

Related APIs:

- [Task guide](https://github.com/libtmux/libtmux-powershell/blob/fa5e60c48b312eb0d957d02aad9edcfc50cff359/docs/capture.md)
- [Tmux release requirements](https://github.com/libtmux/libtmux-powershell/blob/fa5e60c48b312eb0d957d02aad9edcfc50cff359/docs/compatibility.md)

## Examples

Example 1

Read the version of the existing server identified by $SocketPath.

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

```powershell
$arguments = @('display-message', '-p', '#{version}')
LibTmux\New-TmuxServer -SocketPath $SocketPath |
    LibTmux\Invoke-TmuxCommand -Arguments $arguments
```

## Parameters

- `Server` (`LibTmux.Server`): The endpoint that receives the command.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Arguments` (`System.String[]`): Literal arguments beginning with a tmux command name or alias. Global options such as -S, -L and -f cannot replace the command name; configure the endpoint on Server. Invalid command names terminate before confirmation or dispatch.
  Required. Position 1. Does not accept pipeline input. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0). [`ValidateCount(1, 2147483647)`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatecountattribute?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`): Runs the command in a mode that only reports what would happen without performing the actions.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `wi`.
- `Confirm` (`System.Management.Automation.SwitchParameter`): Prompts you for confirmation before running the cmdlet.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `cf`.

## Returns

`LibTmux.TmuxCommandResult`: Native pipeline type for this command.

## Guides

Pages that discuss `Invoke-TmuxCommand`.

- [Capture, refresh and raw commands](/en/powershell/latest/guides/capture/)
- [Compatibility](/en/powershell/latest/guides/compatibility/)
- [Getting started](/en/powershell/latest/guides/getting-started/)
