public/Add-SkylineFieldIndex.ps1
Function Add-SkylineFieldIndex { <# .SYNOPSIS Sets a SharePoint list field to be indexed .DESCRIPTION Sets a SharePoint list field to be indexed .EXAMPLE Set the Title field on the Announcements list to be indexed Add-SkylineFieldIndex -Identity "Title" -List "Announcements" .EXAMPLE Set the Title field on the Announcements list to be indexed on a specific Web which may not be the currently connected web Add-SkylineFieldIndex -Identity "Title" -List "Announcements" -Web $Subweb .PARAMETER Identity Name of the field to update .PARAMETER List Display name of the list which contains the field .PARAMETER Web The web to apply the command to. Omit this parameter to use the current web. #> [cmdletbinding()] param( [parameter(Mandatory = $True)] [string]$Identity = '', [parameter(Mandatory = $True)] [string]$List = '', [Microsoft.SharePoint.Client.Web]$Web ) Process { Write-Debug ( "Running $($MyInvocation.MyCommand).`n" + "PSBoundParameters:`n$($PSBoundParameters | Format-List | Out-String)") Try { $Field = Get-PnPField @PSBoundParameters $Field.Indexed = $True $Field.Update() $Field.Context.ExecuteQuery() } Catch { Throw $_ } } } |