# LibTmux\New-TmuxQuery

- **Package:** LibTmux
- **Language:** PowerShell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/src/LibTmux.PowerShell/NewTmuxQueryCommand.cs#L9
- **Page:** https://libtmux.org/en/powershell/latest/reference/libtmux-new-tmuxquery/

```
Criteria (default):
New-TmuxQuery
    -Target <LibTmux.Query.QueryTarget>
    -Criteria <System.Collections.IDictionary>
    [<CommonParameters>]

Json:
New-TmuxQuery
    -Json <System.String>
    [<CommonParameters>]
```

Build reusable criteria for captured tmux objects.

Construct a native [`LibTmux`](/en/powershell/latest/reference/libtmux/) query document from a criteria map or serialized
schema 2 JSON. Construction copies and validates data without contacting tmux.
Use [`Where-Object`](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/where-object?view=powershell-7.4) for ordinary PowerShell predicates; structured criteria also
support serialization, field discovery and explicit source planning.

Map keys use native property names or catalog wire names. Bare values mean
equality; fields in a map are combined with And. Use operator maps such as
@{ Width = @{ Ge = 80 } }. [`Get-TmuxQueryField`](/en/powershell/latest/reference/libtmux-get-tmuxqueryfield/) lists native catalog fields and operator names. The
[criteria reference](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/query.md#criteria-vocabulary) maps those names to accepted
PowerShell keys such as Ge, Some and Is.
[`Unknown`](/en/csharp/latest/reference/libtmux-tmuxdispatchstate-unknown/) fields, duplicate aliases, unsupported operators, ScriptBlocks, cycles
and oversized data are rejected before evaluation.

### Notes

[`Tmux.InvalidQuery`](https://github.com/libtmux/libtmux-powershell/blob/b06c64f844f3173de66b187eaeaf3915814318c6/docs/reference/LibTmux/New-TmuxQuery.md#notes) terminates invalid construction. The packaged libtmux-query-v2.schema.json describes the JSON representation.

## Command details

- **Command type:** [`cmdlet`](/en/powershell/latest/reference/glossary/#cmdlet)
- **Default parameter set:** Criteria
- **Positional binding:** Enabled.
- **Pipeline inputs:** `None`: No pipeline input.
- **Outputs:** `LibTmux.Query.QueryDocument`

Related APIs:

- [`Select-TmuxPane`](/en/powershell/latest/reference/libtmux-select-tmuxpane/)
- [`Get-TmuxQueryField`](/en/powershell/latest/reference/libtmux-get-tmuxqueryfield/)
- [`ConvertTo-TmuxQueryJson`](/en/powershell/latest/reference/libtmux-convertto-tmuxqueryjson/)

## Examples

Example 1

Build a reusable filter for panes at least 80 columns wide.

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

```powershell
LibTmux\New-TmuxQuery -Target Pane -Criteria @{ Width = @{ Ge = 80 } }
```

## Parameters

- `Target` (`LibTmux.Query.QueryTarget`): The native entity described by Criteria. (for `Criteria`)
  Required. Named parameter. Does not accept pipeline input. [`ValidateSet(["Session","Window","Pane"])`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatesetattribute?view=powershellsdk-7.4.0).
- `Criteria` (`System.Collections.IDictionary`): A bounded data map. Values must have the native field type; strings and Boolean values are not converted to numbers. (for `Criteria`)
  Required. Named parameter. Does not accept pipeline input. [`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`.
- `Json` (`System.String`): A complete document serialized by ConvertTo-TmuxQueryJson. Only the current schema is accepted. (for `Json`)
  Required. Named parameter. Does not accept pipeline input. [`ValidateNotNullOrEmpty()`](https://learn.microsoft.com/dotnet/api/system.management.automation.validatenotnulloremptyattribute?view=powershellsdk-7.4.0).

## Returns

`LibTmux.Query.QueryDocument`: One validated native document.
