Skip to content

New AcmaQuery

Ryan Newington edited this page Sep 4, 2025 · 7 revisions

New-AcmaQuery

Description

Creates a new query that searches for a particular attribute value. This cmdlet generates a DBQueryObject that can be used with the Get-AcmaObjects cmdlet

Syntax

New-AcmaQuery -Attribute <string> -Operator <AcmaComparisonOperator> -Value <object>
New-AcmaQuery -Attribute <string> -Operator <AcmaComparisonOperator> -Declaration <string>

Parameters

Attribute (String)

The name of the attribute to query

  • Required: Yes
  • Position: Named
  • Pipeline input: No

Operator (AcmaComparisonOperator)

The type of comparison operation to perform. Valid values include:

  • Equals - Exact match
  • NotEquals - Does not equal
  • Contains - Contains the specified value
  • NotContains - Does not contain the specified value
  • StartsWith - Starts with the specified value
  • EndsWith - Ends with the specified value
  • GreaterThan - Greater than (numeric/date comparison)
  • GreaterThanOrEquals - Greater than or equal to
  • LessThan - Less than (numeric/date comparison)
  • LessThanOrEquals - Less than or equal to
  • IsPresent - Attribute has any value
  • IsNotPresent - Attribute has no value

Required: Yes Position: Named Pipeline input: No

Value (Object)

The value to compare against the attribute

  • Required: Yes (when not using Declaration)
  • Position: Named
  • Pipeline input: No
  • Accepts: String, Integer, DateTime, Boolean, or other appropriate type

Declaration (String)

A declarative expression to evaluate for the comparison value

  • Required: Yes (when not using Value)
  • Position: Named
  • Pipeline input: No

Return Type

Returns an AcmaDBQueryObject that can be used with Get-AcmaObjects

Examples

Basic string comparison

$query = New-AcmaQuery -Attribute "accountName" -Operator StartsWith -Value "r"
$objects = Get-AcmaObjects $query

Numeric comparison

$query = New-AcmaQuery -Attribute "deleted" -Operator GreaterThan -Value 0
$objects = Get-AcmaObjects $query

Exact match query

$query = New-AcmaQuery -Attribute "department" -Operator Equals -Value "Finance"
$objects = Get-AcmaObjects $query

Using declarative expressions

$query = New-AcmaQuery -Attribute "mailNickname" -Operator Equals -Declaration "{givenName}.{sn}"
$objects = Get-AcmaObjects $query

Presence check

$query = New-AcmaQuery -Attribute "manager" -Operator IsPresent
$objects = Get-AcmaObjects $query

Clone this wiki locally