# LibTmux.Workspace\Invoke-TmuxWorkspace

- **Package:** LibTmux.Workspace
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.Workspace.PowerShell/InvokeTmuxWorkspaceCommand.cs#L8
- **Page:** https://libtmux.org/en/powershell/latest/workspace/reference/libtmux-workspace-invoke-tmuxworkspace/

```
Invoke-TmuxWorkspace
    [-Plan] <LibTmux.Workspace.WorkspacePlan>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]
```

Apply the exact workspace plan after one confirmation.

Apply the supplied native WorkspacePlan using its own endpoint, observed
identities and frozen actions. No declaration, file, endpoint or policy can be
substituted at invocation. Stale preconditions fail; invocation never replans or
retries mutations automatically.

[`One`](/en/csharp/latest/reference/libtmux-query-queryrelationcardinality-one/) PowerShell ShouldProcess decision covers the whole plan. Its target names
the executable, socket and literal session name. Its action describes conflict,
startup, readiness and compensation policy, global option effects, then lists
every action and conditional cleanup step in order by kind and symbolic target.
Option actions disclose scope and whether they change global defaults;
request values are omitted. Inspect the original plan for full request and
host-command values.
[`WhatIf`](/en/powershell/latest/workspace/reference/libtmux-workspace-invoke-tmuxworkspace/#LibTmux.Workspace%5CInvoke-TmuxWorkspace.parameter.WhatIf) and declined confirmation perform no application I/O or cleanup and
emit no WorkspaceResult.

Successful invocation returns one native WorkspaceResult containing the session,
created windows, unsupported layouts and action journals. WorkspaceBuildException
remains ErrorRecord.Exception under Tmux.WorkspaceApplyFailed, with the original
plan as TargetObject. Inspect its [`Dispatch`](/en/csharp/latest/reference/libtmux-libtmuxexception-dispatch/), InnerException, PartialResult,
Journal and CompensationJournal; partial results are never emitted as success.

Stopping the pipeline cancels owned work. Cleanup follows the plan's frozen
budget. A stopped pipeline can suppress subsequent error output, so receiving a
cancellation journal after pipeline shutdown is not guaranteed. Application is
detached; it does not attach a terminal or transfer ownership of the daemon.
To enter the applied session, pass the successful WorkspaceResult.Session to
[`Enter-TmuxSession`](/en/powershell/latest/reference/libtmux-enter-tmuxsession/) in a foreground terminal outside tmux. Attachment has its own
confirmation and cancellation behavior; it does not repeat application.

### Notes

Replace is an explicit planning policy. Compensation can remove only creations
whose ownership is established by the native journal; shell and host-script
effects cannot be undone. Reuse returns the existing session without running
workspace mutation or host actions.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/workspace/reference/glossary/#cmdlet)
- **Confirmation:** Supports `-WhatIf` and `-Confirm`; confirm impact: High.
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Workspace.WorkspacePlan`: A native plan prepared by Get-TmuxWorkspacePlan or the shared .NET API.
- **Outputs:** `LibTmux.Workspace.WorkspaceResult`

Related APIs:

- [`Get-TmuxWorkspacePlan`](/en/powershell/latest/workspace/reference/libtmux-workspace-get-tmuxworkspaceplan/)
- [`Enter-TmuxSession`](/en/powershell/latest/reference/libtmux-enter-tmuxsession/)

## Examples

Example 1

Preview an existing plan created by Get-TmuxWorkspacePlan without applying it.

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

```powershell
$Plan | LibTmux.Workspace\Invoke-TmuxWorkspace -WhatIf
```

Example 2

Apply that reviewed plan with the normal confirmation explicitly disabled.

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

```powershell
$Plan | LibTmux.Workspace\Invoke-TmuxWorkspace -Confirm:$false
```

## Parameters

- `Plan` (`LibTmux.Workspace.WorkspacePlan`): The exact native plan to apply. Its endpoint, actions, creation identity checks and cleanup policies are preserved.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?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`): Describe the whole plan without tmux inspection, host execution, mutation or cleanup. No success object is returned.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `wi`. Documented default: `False`.
- `Confirm` (`System.Management.Automation.SwitchParameter`): Request normal PowerShell confirmation for the whole reviewed plan. The command has High confirmation impact.
  Optional. Named parameter. Switch parameter. Does not accept pipeline input. Aliases: `cf`. Documented default: `False`.

## Returns

`LibTmux.Workspace.WorkspaceResult`: One completed native result. Preview and declined confirmation emit nothing.

## In other ports

### Build a session from a workspace description

- Julia: [`LibTmuxWorkspace.apply`](/en/julia/latest/workspace/reference/libtmuxworkspace-apply/) (function). Applies a prepared `WorkspacePlan` on an explicit `Server`, detached and under one deadline. Existing session names fail unless reuse is explicit.
- Python: [`tmuxp.workspace.builder.ClassicWorkspaceBuilder.build`](/en/py/latest/workspace/reference/tmuxp-workspace-builder-classicworkspacebuilder-build/) (method)
- Ruby: [`LibTmux::Workspace::Plan#apply`](/en/ruby/latest/workspace/reference/libtmux-workspace-plan-apply/) (method)
- TypeScript: [`builder.applyWorkspace`](/en/ts/latest/workspace/reference/builder-applyworkspace/) (function)
- Rust: [`src.WorkspaceBuilder.build`](/en/rs/latest/workspace/reference/src-workspacebuilder-build/) (method)
- Go: [`workspace.Build`](/en/go/latest/workspace/reference/workspace-build/) (function)
- Java: [`io.github.libtmux.workspace.WorkspaceBuilder.WorkspaceBuilder.build`](/en/java/latest/workspace/reference/io-github-libtmux-workspace-workspacebuilder-workspacebuilder-build/) (method)
- C#: [`LibTmux.Workspace.WorkspaceBuilder.BuildAsync`](/en/csharp/latest/workspace/reference/libtmux-workspace-workspacebuilder-buildasync/) (method)
- C++: [`libtmux::workspace::build`](/en/cxx/latest/workspace/reference/libtmux-workspace-build/) (function)
- Swift: [`WorkspaceBuilder.build(_:on:)`](/en/swift/latest/workspace/reference/workspacebuilder-build(_-on-)/) (method)
