# LibTmux\Invoke-TmuxCommand

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/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.

### 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/b06c64f844f3173de66b187eaeaf3915814318c6/docs/capture.md)

## Examples

Example 1

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

[Source example](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/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.
