|
| 1 | +--- |
| 2 | +Module Name: PnP.PowerShell |
| 3 | +schema: 2.0.0 |
| 4 | +applicable: SharePoint Online |
| 5 | +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSearchResultType.html |
| 6 | +external help file: PnP.PowerShell.dll-Help.xml |
| 7 | +title: Get-PnPSearchResultType |
| 8 | +--- |
| 9 | + |
| 10 | +# Get-PnPSearchResultType |
| 11 | + |
| 12 | +## SYNOPSIS |
| 13 | + |
| 14 | +**Required Permissions** |
| 15 | + |
| 16 | + * [Graph Connector Service (GCS) API](#prerequisites) |
| 17 | + * Site scope: Site Administrator |
| 18 | + * Organization scope: Search Administrator or Global Administrator |
| 19 | + |
| 20 | +Retrieves Microsoft Search result types configured for the currently connected site or at the organization level. |
| 21 | + |
| 22 | +## SYNTAX |
| 23 | + |
| 24 | +```powershell |
| 25 | +Get-PnPSearchResultType [-Identity <String>] [-Scope <SearchVerticalScope>] [-Verbose] [-Connection <PnPConnection>] |
| 26 | +``` |
| 27 | + |
| 28 | +## DESCRIPTION |
| 29 | + |
| 30 | +This cmdlet retrieves the Microsoft Search result types configured for the site you are currently connected to, or at the organization (tenant) level when using `-Scope Organization`. Result types define how search results are displayed using Adaptive Card templates. They can be configured for SharePoint content or external connector content. It uses the Graph Connector Service (GCS) API at gcs.office.com. |
| 31 | + |
| 32 | +> [!WARNING] |
| 33 | +> This cmdlet uses the Graph Connector Service (GCS) API, which is an internal Microsoft API that is not publicly documented or officially supported. It may change without notice. |
| 34 | +
|
| 35 | +### Prerequisites |
| 36 | + |
| 37 | +Your Entra app registration must have the `ExternalConnection.ReadWrite.All` delegated permission from the Graph Connector Service (GCS) API. To add this permission using Azure CLI: |
| 38 | + |
| 39 | +```bash |
| 40 | +az ad app permission add --id <your-app-id> --api 56c1da01-2129-48f7-9355-af6d59d42766 --api-permissions d44774bd-e26c-43b1-996d-51bb90a9078e=Scope |
| 41 | +az ad app permission admin-consent --id <your-app-id> |
| 42 | +``` |
| 43 | + |
| 44 | +> [!NOTE] |
| 45 | +> This cmdlet requires a **delegated (interactive)** connection. App-only (certificate-based) connections are not supported by the GCS API and will result in a 403 Forbidden error. |
| 46 | +
|
| 47 | +## EXAMPLES |
| 48 | + |
| 49 | +### EXAMPLE 1 |
| 50 | +```powershell |
| 51 | +Get-PnPSearchResultType |
| 52 | +``` |
| 53 | + |
| 54 | +Returns all search result types for the currently connected site. |
| 55 | + |
| 56 | +### EXAMPLE 2 |
| 57 | +```powershell |
| 58 | +Get-PnPSearchResultType -Identity "1770839639348_FYXB8XQI5" |
| 59 | +``` |
| 60 | + |
| 61 | +Returns the search result type with the specified logical ID. |
| 62 | + |
| 63 | +### EXAMPLE 3 |
| 64 | +```powershell |
| 65 | +Get-PnPSearchResultType -Identity "My Result Type" |
| 66 | +``` |
| 67 | + |
| 68 | +Returns the search result type with the specified name. |
| 69 | + |
| 70 | +### EXAMPLE 4 |
| 71 | +```powershell |
| 72 | +Get-PnPSearchResultType -Scope Organization |
| 73 | +``` |
| 74 | + |
| 75 | +Returns all organization-level search result types. |
| 76 | + |
| 77 | +### EXAMPLE 5 |
| 78 | +```powershell |
| 79 | +Get-PnPSearchResultType -Identity "1770839639348_FYXB8XQI5" | Select-Object -ExpandProperty Payload | Select-Object -ExpandProperty Rules |
| 80 | +``` |
| 81 | + |
| 82 | +Shows the rules configured for a specific result type. |
| 83 | + |
| 84 | +### EXAMPLE 6 |
| 85 | +```powershell |
| 86 | +Get-PnPSearchResultType | Where-Object { $_.Payload.IsActive -eq $false } | Remove-PnPSearchResultType |
| 87 | +``` |
| 88 | + |
| 89 | +Pipes inactive result types directly to `Remove-PnPSearchResultType`. The `LogicalId` property binds automatically to `-Identity`. |
| 90 | + |
| 91 | +## PARAMETERS |
| 92 | + |
| 93 | +### -Connection |
| 94 | +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing [Get-PnPConnection](Get-PnPConnection.md). |
| 95 | + |
| 96 | +```yaml |
| 97 | +Type: PnPConnection |
| 98 | +Parameter Sets: (All) |
| 99 | +Required: False |
| 100 | +Position: Named |
| 101 | +Default value: None |
| 102 | +Accept pipeline input: False |
| 103 | +Accept wildcard characters: False |
| 104 | +``` |
| 105 | +
|
| 106 | +### -Identity |
| 107 | +The logical ID or name of the search result type to retrieve. Logical IDs are in the format `{timestamp}_{randomId}`. If a name is provided, the cmdlet searches all result types for a matching name. If not provided, all result types will be returned. |
| 108 | + |
| 109 | +```yaml |
| 110 | +Type: String |
| 111 | +Parameter Sets: (All) |
| 112 | +Required: False |
| 113 | +Position: 0 |
| 114 | +Default value: None |
| 115 | +Accept pipeline input: True (ByValue, ByPropertyName) |
| 116 | +Accept wildcard characters: False |
| 117 | +Aliases: LogicalId |
| 118 | +``` |
| 119 | + |
| 120 | +### -Scope |
| 121 | +Specifies whether to retrieve site-level or organization-level result types. Defaults to Site. |
| 122 | + |
| 123 | +```yaml |
| 124 | +Type: SearchVerticalScope |
| 125 | +Parameter Sets: (All) |
| 126 | +Accepted values: Site, Organization |
| 127 | +Required: False |
| 128 | +Position: Named |
| 129 | +Default value: Site |
| 130 | +Accept pipeline input: False |
| 131 | +Accept wildcard characters: False |
| 132 | +``` |
| 133 | + |
| 134 | +### -Verbose |
| 135 | +When provided, additional debug statements will be shown while executing the cmdlet. |
| 136 | + |
| 137 | +```yaml |
| 138 | +Type: SwitchParameter |
| 139 | +Parameter Sets: (All) |
| 140 | +Required: False |
| 141 | +Position: Named |
| 142 | +Default value: None |
| 143 | +Accept pipeline input: False |
| 144 | +Accept wildcard characters: False |
| 145 | +``` |
| 146 | + |
| 147 | +## OUTPUT |
| 148 | + |
| 149 | +Returns one or more `SearchResultType` objects with the following properties: |
| 150 | + |
| 151 | +| Property | Type | Description | |
| 152 | +|----------|------|-------------| |
| 153 | +| Path | String | Site path in the format `:GUID:` | |
| 154 | +| LogicalId | String | Unique identifier (e.g. `1770839639348_FYXB8XQI5`) | |
| 155 | +| LastModifiedDateTime | String | Timestamp of last modification | |
| 156 | +| Payload | SearchResultTypePayload | The result type configuration (see below) | |
| 157 | + |
| 158 | +The `Payload` object contains: |
| 159 | + |
| 160 | +| Property | Type | Description | |
| 161 | +|----------|------|-------------| |
| 162 | +| Name | String | Display name of the result type | |
| 163 | +| IsActive | Boolean | Whether the result type is active | |
| 164 | +| Priority | Int | Priority order (1 = highest; lower numbers indicate higher priority) | |
| 165 | +| ContentSourceId | Object | Content source with `ContentSourceApplication`, `Identity`, `SystemId` | |
| 166 | +| ContentSourceName | String | Display name of the content source | |
| 167 | +| Rules | List | Matching rules (see below) | |
| 168 | +| DisplayTemplate | String | Adaptive Card JSON template | |
| 169 | +| DisplayProperties | List | Properties used in the display template | |
| 170 | + |
| 171 | +Each rule in `Rules` contains: |
| 172 | + |
| 173 | +| Property | JSON Key | Type | Description | |
| 174 | +|----------|----------|------|-------------| |
| 175 | +| PropertyName | PN | String | Property to match (e.g. "FileType", "IsListItem") | |
| 176 | +| Operator | PO | Object | Operator with `N` code and `JBO` flag | |
| 177 | +| Values | PV | List | Values to compare against | |
| 178 | + |
| 179 | +Operator `N` codes: 1=Equals, 2=NotEquals, 3=Contains, 4=DoesNotContain, 5=LessThan, 6=GreaterThan, 7=StartsWith. Use [New-PnPSearchResultTypeRule](New-PnPSearchResultTypeRule.md) to create rules with friendly operator names. |
| 180 | + |
| 181 | +## RELATED LINKS |
| 182 | + |
| 183 | +[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) |
0 commit comments