I can manually set an index on a column in a large SharePoint list (10000+ items) but I'm not able to do it programmatically.

With (PnP) PowerShell I've tried:

# get context
$Context = Get-PnPContext     
# set 
$fieldtocheck.indexed = $true

The last part ($Context.ExecuteQuery()) fails on a large list.

I've also tried using graph:

$uri = "https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/contosesite:/lists/listguid/columns/columntobeindexed"

$json = @'
Invoke-MgGraphRequest -uri $uri -body $json -Method PATCH -ContentType "application/json"

which also fails with: The request is unprocessable because it uses too many resources.

Is there a way without doing it manually by setting an index on a colummn in a large list? Thanks in advance.

3 Answers 3


There is a trick!

  1. Delete a few items until you are below (maybe) 5000 items.
  2. After that, try to index the field.
  3. Once it works, go to the site recycle bin and restore the deleted items

You could use following PowerShell to create Index column.

#Config Variables
$SiteURL = "https://Crescent.sharepoint.com"
$ListName = "Projects"
$ColumnName = "ProjectName" #Internal Name
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Get the Context
$Context = Get-PnPContext
#Get the Field from List
$Field = Get-PnPField -List $ListName -Identity $ColumnName
#Set the Indexed Property of the Field
$Field.Indexed = $True

i was searching for this too and have found solution :

$field = Get-PnPField -List '<LIST_NAME>' -Identity '<FIELD_NAME>'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.