# LibTmux\Get-TmuxSession

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

```
Get-TmuxSession
    [-Server] <LibTmux.Server>
    [-Id <System.String>]
    [-Name <System.String>]
    [<CommonParameters>]
```

Read sessions with optional exact selectors.

Acquire sessions from a native [`Server`](/en/csharp/latest/reference/libtmux-server/). Id and Name are ordinal, case-sensitive literal selectors; combining them requires both to match. Wildcards are not expanded. An unmatched selector emits nothing; a failed acquisition writes an error.

### Notes

Wrap results in @() when a stable array is needed. A missing daemon is an error, not a successful empty list. [`Session`](/en/csharp/latest/reference/libtmux-session/)-only capture does not acquire windows.

## 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.Session`

Related APIs:

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

## Examples

Example 1

List sessions on the existing server identified by $SocketPath.

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

```powershell
LibTmux\New-TmuxServer -SocketPath $SocketPath | LibTmux\Get-TmuxSession
```

## Parameters

- `Server` (`LibTmux.Server`): The server whose sessions are 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).
- `Id` (`System.String`): An ordinal, literal session identifier selector.
  Optional. Named parameter. Does not accept pipeline input. [`ArgumentCompleter("LibTmux.PowerShell.SessionSelectorCompleter")`](https://learn.microsoft.com/dotnet/api/system.management.automation.argumentcompleterattribute?view=powershellsdk-7.4.0). [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).
- `Name` (`System.String`): An ordinal, literal session name selector.
  Optional. Named parameter. Does not accept pipeline input. [`ArgumentCompleter("LibTmux.PowerShell.SessionSelectorCompleter")`](https://learn.microsoft.com/dotnet/api/system.management.automation.argumentcompleterattribute?view=powershellsdk-7.4.0). [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?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.Session`: Native pipeline type for this command.

## tmux command

The tmux commands behind `Get-TmuxSession`.

- [`list-sessions`](/en/tmux/latest/manual/list-sessions/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_list_sessions_entry`](/en/tmux/latest/reference/c-variable-cmd_list_sessions_entry/) (attribute)
- [`cmd_list_sessions_exec`](/en/tmux/latest/reference/c-function-cmd-list-sessions-c-cmd_list_sessions_exec/) (function)

## Guides

Pages that discuss `Get-TmuxSession`.

### Concepts

- [Captured state and I/O](/en/powershell/latest/concepts/captured-state/)

### Guides

- [Attaching to tmux](/en/powershell/latest/guides/attaching-to-tmux/)
- [Read tmux objects](/en/powershell/latest/guides/read/)

## In other ports

A tmux session

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Session`](/en/py/latest/reference/libtmux-session/) (class) |
| Ruby | [`LibTmux::Session`](/en/ruby/latest/reference/libtmux-session-nvps/) (class) |
| Lua | [`libtmux.Session`](/en/lua/latest/reference/libtmux-session/) (class) |
| Julia | [`LibTmux.SessionSnapshot`](/en/julia/latest/reference/libtmux-sessionsnapshot/) (struct). `SessionSnapshot` holds captured session data. Actions use its `SessionRef`, a typed identity bound to an observed daemon generation. |
| Elixir | [`LibTmux.Session`](/en/elixir/latest/reference/libtmux-session/) (struct). `Session` is an immutable observation. Fields not captured read as `:unloaded`. |
| TypeScript | [`session.Session`](/en/ts/latest/reference/session-session/) (class) |
| Rust | [`session.Session`](/en/rs/latest/reference/session-session/) (struct) |
| Go | [`tmux.Session`](/en/go/latest/reference/tmux-session/) (struct) |
| Java | [`io.github.libtmux.Session`](/en/java/latest/reference/io-github-libtmux-session-session/) (class) |
| Kotlin | [`io.github.libtmux.kotlin.Session`](/en/kotlin/latest/reference/io-github-libtmux-kotlin-session/) (class) |
| Scala | [`io.github.libtmux.scaladsl.Session`](/en/scala/latest/reference/io-github-libtmux-scaladsl-session/) (typealias) |
| C# | [`LibTmux.Session`](/en/csharp/latest/reference/libtmux-session/) (class) |
| F# | [`LibTmux.FSharp.Session`](/en/fsharp/latest/reference/libtmux-fsharp-session/) (module). This F# module builds deferred child queries from a shared .NET `LibTmux.Session` and its server association. `Query.list` acquires their results from tmux. |
| C++ | [`libtmux::Session`](/en/cxx/latest/reference/libtmux-session/) (class) |
| Swift | [`Session`](/en/swift/latest/reference/session/) (struct) |

List the server’s sessions

| Language | Equivalent |
| --- | --- |
| Python | [`libtmux.Server.sessions`](/en/py/latest/reference/libtmux-server-sessions/) (property) |
| Ruby | [`LibTmux::Server#list_sessions`](/en/ruby/latest/reference/libtmux-server-list_sessions/) (method) |
| Lua | [`libtmux.Snapshot.sessions`](/en/lua/latest/reference/libtmux-snapshot-sessions/) (attribute) |
| Julia | [`LibTmux.sessions`](/en/julia/latest/reference/libtmux-sessions/) (function). `sessions` reads membership from a captured `Snapshot` without contacting tmux. |
| Elixir | [`LibTmux.Snapshot.sessions/1`](/en/elixir/latest/reference/libtmux-snapshot-sessions-1/) (function). Returns a `Selection` of captured sessions without contacting tmux. |
| TypeScript | [`server.Server.sessions`](/en/ts/latest/reference/server-server-sessions/) (method) |
| Rust | [`server.Server.sessions`](/en/rs/latest/reference/server-server-sessions/) (method) |
| Go | [`tmux.Server.Sessions`](/en/go/latest/reference/tmux-server-sessions/) (method) |
| Java | [`io.github.libtmux.Server.sessions`](/en/java/latest/reference/io-github-libtmux-server-server-sessions/) (method) |
| Kotlin | [`io.github.libtmux.kotlin.Server.sessions`](/en/kotlin/latest/reference/io-github-libtmux-kotlin-server-sessions/) (method) |
| Scala | [`io.github.libtmux.scaladsl.Server.sessions`](/en/scala/latest/reference/io-github-libtmux-scaladsl-server-sessions/) (method) |
| C# | [`LibTmux.Server.Sessions`](/en/csharp/latest/reference/libtmux-server-sessions/) (property) |
| F# | [`LibTmux.FSharp.Server.sessions`](/en/fsharp/latest/reference/libtmux-fsharp-server-sessions/) (function). Builds a deferred session query on `LibTmux.Server`. `Query.list` acquires the results; it does not traverse the handle’s captured membership. |
| C++ | [`libtmux::Server::sessions`](/en/cxx/latest/reference/libtmux-server-sessions/) (method) |
| Swift | [`Server.sessions()`](/en/swift/latest/reference/server-sessions()/) (method) |
