Skip to content

Fix Resolve-PnPFolder exceeding the list view threshold on large libraries - #5411

Open
svermaak wants to merge 1 commit into
pnp:devfrom
svermaak:fix/resolve-pnpfolder-listview-threshold
Open

Fix Resolve-PnPFolder exceeding the list view threshold on large libraries#5411
svermaak wants to merge 1 commit into
pnp:devfrom
svermaak:fix/resolve-pnpfolder-listview-threshold

Conversation

@svermaak

@svermaak svermaak commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Type of change

  • Bug fix

Related issue

Fixes #2286 (and the earlier regression of #1438)

What is in this Pull Request

Resolve-PnPFolder delegated to PnP Framework's Web.EnsureFolderPath, which checks every path segment by loading the entire Folders collection of the parent folder and iterating it to find the child. That collection load is a list query, so as soon as any folder in the path resides in a scope holding more than 5000 items, SharePoint rejects it with "The attempted operation is prohibited because it exceeds the list view threshold."

This PR resolves the folder path inside the cmdlet itself using direct path addressing, the same threshold-safe pattern already used by Get-PnPFolder, Copy-PnPFile and Move-PnPFile:

  • First probes the full target URL with GetFolderByServerRelativePath(ResourcePath.FromDecodedUrl(...)) loading only Exists. When the folder already exists this is a single round trip (the previous implementation issued one query per path segment).
  • When it does not exist, walks the path segment by segment, probing each the same way and creating missing folders with Folders.AddUsingPath, which performs an add without enumerating the collection.
  • -Includes retrieval expressions are still honored on the returned folder.

No folder or item collection is ever enumerated, so the list view threshold no longer applies regardless of folder size.

…aries

Resolve-PnPFolder delegated to PnP Framework's EnsureFolderPath, which
enumerates the entire Folders collection of every path segment. On folders
holding more than 5000 items that query exceeds the list view threshold.

Replaced with direct GetFolderByServerRelativePath probes (loading only
Exists) and Folders.AddUsingPath for missing segments, so no folder
collection is ever enumerated.

Fixes pnp#2286
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Resolve-PnPFolder: The attempted operation is prohibited because it exceeds the list view threshold.

1 participant