# LibTmux\Get-TmuxSession

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

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

```
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/b06c64f844f3173de66b187eaeaf3915814318c6/docs/read.md)

## Examples

Example 1

List sessions on the existing server identified by $SocketPath.

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

## In other ports

### A tmux session

- 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.
- 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)
- 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.Session`](/en/java/latest/reference/io-github-libtmux-session-session/) (class)
- C#: [`LibTmux.Session`](/en/csharp/latest/reference/libtmux-session/) (class)
- C++: [`libtmux::Session`](/en/cxx/latest/reference/libtmux-session/) (class)
- Swift: [`Session`](/en/swift/latest/reference/session/) (struct)
- 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)
- 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.

### List the server’s sessions

- Julia: [`LibTmux.sessions`](/en/julia/latest/reference/libtmux-sessions/) (function). `sessions` reads membership from a captured `Snapshot` without contacting tmux.
- 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)
- 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.Server.sessions`](/en/java/latest/reference/io-github-libtmux-server-server-sessions/) (method)
- C#: [`LibTmux.Server.Sessions`](/en/csharp/latest/reference/libtmux-server-sessions/) (property)
- C++: [`libtmux::Server::sessions`](/en/cxx/latest/reference/libtmux-server-sessions/) (method)
- Swift: [`Server.sessions()`](/en/swift/latest/reference/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)
- 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.
