Table of Contents

New-PnPSearchResultTypeRule

SYNOPSIS

Creates a rule object for use with Microsoft Search result types.

SYNTAX

New-PnPSearchResultTypeRule -PropertyName <String> -Operator <SearchResultTypeRuleOperatorType> -Values <String[]>

DESCRIPTION

This cmdlet creates a SearchResultTypeRule object that can be passed to New-PnPSearchResultType -Rules or used when constructing result type payloads. Rules define conditions that determine which search results match a result type.

EXAMPLES

EXAMPLE 1

New-PnPSearchResultTypeRule -PropertyName "FileType" -Operator Equals -Values "pdf"

Creates a rule that matches results where FileType equals "pdf".

EXAMPLE 2

$rules = @(
    New-PnPSearchResultTypeRule -PropertyName "FileType" -Operator Equals -Values "docx","xlsx"
    New-PnPSearchResultTypeRule -PropertyName "IsListItem" -Operator Equals -Values "true"
)
New-PnPSearchResultType -Name "Office List Items" -Rules $rules

Creates multiple rules and uses them to create a result type.

EXAMPLE 3

New-PnPSearchResultTypeRule -PropertyName "IconUrl" -Operator StartsWith -Values "https://"

Creates a rule using the StartsWith operator.

PARAMETERS

-PropertyName

The property name to match against (e.g., "FileType", "IsListItem", "IconUrl").

Type: String
Parameter Sets: (All)
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Operator

The comparison operator for the rule.

Type: SearchResultTypeRuleOperatorType
Parameter Sets: (All)
Accepted values: Equals, NotEquals, Contains, DoesNotContain, LessThan, GreaterThan, StartsWith
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Values

One or more values to compare against.

Type: String[]
Parameter Sets: (All)
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Microsoft 365 Patterns and Practices