# LibTmux\Get-TmuxSnapshot

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

```
Get-TmuxSnapshot
    [-Server] <LibTmux.Server>
    [-Depth <LibTmux.SnapshotDepth>]
    [<CommonParameters>]
```

Capture a replacement tmux hierarchy.

Read the explicit server endpoint to the requested [`Depth`](/en/csharp/latest/reference/libtmux-snapshotmetadata-depth/). The default Panes
depth captures sessions, contextual windows and panes. Shallower snapshots
leave deeper relations unavailable. The input handle and previous captures
remain unchanged.

[`SnapshotMetadata`](/en/csharp/latest/reference/libtmux-snapshotmetadata/) records depth, daemon generation, UTC start/end readings and
monotonic Elapsed time. Use Elapsed for duration because UTC can be adjusted.
Even [`Server`](/en/csharp/latest/reference/libtmux-server/) depth performs a fresh generation-guarded read.

Captured parents and active children retain their exact graph instances when
the requested depth includes them. Repeated links keep their session/index
placement; filtering panes does not prune their parent's captured relations.

### Notes

Acquisition spans multiple tmux commands and does not promise an atomic view.
Contradictory topology or active references fail with [`InconsistentSnapshotException`](/en/csharp/latest/reference/libtmux-inconsistentsnapshotexception/)
without publishing a partial graph or retrying. Equal-count changes can escape
detection. [`Tmux.SnapshotFailed`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/Get-TmuxSnapshot.md#notes) retains the native exception and target; use
[`ErrorAction`](/en/powershell/latest/reference/libtmux-get-tmuxsnapshot/#LibTmux%5CGet-TmuxSnapshot.parameter.ErrorAction) Stop to stop later owners. Property access uses captured data;
unavailable relations throw rather than appearing empty.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Positional binding:** Enabled.
- **Pipeline inputs:** `LibTmux.Server`: Native pipeline type for this command.
- **Outputs:** `LibTmux.Server`

Related APIs:

- [Task guide](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/read.md)

## Examples

Example 1

Capture the hierarchy of the existing server identified by $SocketPath.

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

```powershell
LibTmux\New-TmuxServer -SocketPath $SocketPath |
    LibTmux\Get-TmuxSnapshot -Depth Panes
```

## Parameters

- `Server` (`LibTmux.Server`): The server to read.
  Required. Position 0. Accepts pipeline input by value. [`ValidateNotNull()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnullattribute?view=powershellsdk-7.4.0).
- `Depth` (`LibTmux.SnapshotDepth`): The deepest hierarchy level to capture.
  Optional. Named parameter. Does not accept pipeline input. [`ValidateSet(["Server","Sessions","Windows","Panes"])`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatesetattribute?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`.

## Returns

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

## In other ports

### Capture the tmux hierarchy

- Julia: [`LibTmux.snapshot`](/en/julia/latest/reference/libtmux-snapshot-1gv6/) (function). Acquires a new `Snapshot` over an observation interval. Topology checks do not make it a transaction; earlier snapshots do not refresh.
- Ruby: [`LibTmux::Server#snapshot`](/en/ruby/latest/reference/libtmux-server-snapshot/) (method)
- Lua: [`libtmux.Server:snapshot`](/en/lua/latest/reference/libtmux-server-snapshot/) (method)
- TypeScript: [`server.Server.snapshot`](/en/ts/latest/reference/server-server-snapshot/) (method)
- Go: [`tmux.Server.Snapshot`](/en/go/latest/reference/tmux-server-snapshot/) (method)
- Java: [`io.github.libtmux.Server.Server.snapshot`](/en/java/latest/reference/io-github-libtmux-server-server-snapshot/) (method)
- C#: [`LibTmux.Server.CaptureSnapshotAsync`](/en/csharp/latest/reference/libtmux-server-capturesnapshotasync/) (method)
- Swift: [`Server.snapshot()`](/en/swift/latest/reference/server-snapshot()/) (method)
- Kotlin: [`io.github.libtmux.kotlin.Server.snapshot`](/en/kotlin/latest/reference/io-github-libtmux-kotlin-server-snapshot/) (method)
- Scala: [`io.github.libtmux.scaladsl.Server.snapshot`](/en/scala/latest/reference/io-github-libtmux-scaladsl-server-snapshot/) (method)
- F#: [`LibTmux.FSharp.Server.capture`](/en/fsharp/latest/reference/libtmux-fsharp-server-capture/) (function). Acquires a replacement shared .NET `LibTmux.Server` to the requested depth. Acquisition is not atomic; retained handles do not refresh.
