New-AdmCriteria

Creates a new instance of Criteria class that is used for performing directory object queries.

  • New-AdmCriteria

Description

The New-AdmCriteria cmdlet creates a new Criteria object.

The Type parameter specifies the object types this criteria should match e.g. User, Computer.

The Expression parameter specifies the criteria expression to apply to all specified types. Criteria expressions let you define more detailed queries based on the objects' property values e.g. {department -eq "Sales"}. If Type is not specified, the expression will be applied to All object types.

Both parameters are optional. If no parameters are specified, this cmdlet will create an empty criteria that matches all objects.

Examples

Example 1 – Create a criteria matching only users

New-AdmCriteria -Type "User"

Example 2 – Create a criteria matching users and computers

New-AdmCriteria "User","Computer"

Example 3 – Create a criteria matching only users from a certain department

New-AdmCriteria -Type "User" -Expression {department -eq "Sales"}

Example 4 – Create a criteria matching all objects with empty description

New-AdmCriteria "*" {description -empty $true}

Example 4 – Create a criteria matching all objects whose name starts with Admin

New-AdmCriteria -Expression {name -startstwith "Admin"}

For more details about building criteria expressions, see How to build criteria.

Parameters

-Type

Specifies the name of the object type this criteria should match. The name must be specified exactly as it is defined in your directory schema.

You can also use the wildcard object type, the * character. If * is the only included object type, it will translate to All object types. If any particular object type is included along with the wildcard, then * will translate to All other object types.

  • Type:

  • string[]

  • Position:

  • 0

  • Required:

  • False

  • Default Value:

  • None

  • Accept pipeline input:

  • False

  • Accept wildcard characters:

  • False

-Expression

Specifies a criteria expression. The expression will be applied to all included object types.

The expression will be applied to All object types if the Type parameter is not specified.

  • Type:

  • string

  • Position:

  • 1

  • Required:

  • False

  • Default Value:

  • None

  • Accept pipeline input:

  • False

  • Accept wildcard characters:

  • False

Inputs

None

Outputs

Returns the new Criteria object.

See also