Skip to content

Conversation

irvcov
Copy link
Contributor

@irvcov irvcov commented Sep 26, 2025

Before creating a pull request, make sure that you have read the contribution file located at

https://github.com/pnp/powerShell/blob/dev/CONTRIBUTING.md

Type

  • Bug Fix
  • New Feature
  • Sample

What is in this Pull Request ?

Description

This PR introduces a workaround to mitigate List View Threshold (LVT) errors encountered during recycle bin restore operations using Restore-PnPRecycleBinItem in SharePoint Online.
Previously, the cmdlet attempted to retrieve the recycle bin item via Identity.GetRecycleBinItem(Connection.PnPContext), which could trigger LVT violations when the recycle bin is large enough to exceed the list view limit.

image

This update adds logic to detect when Identity.Item is already populated and, in such cases, bypasses the call to GetRecycleBinItem. This allows the cmdlet to restore items directly from the provided object, avoiding enumeration of the entire recycle bin collection.

Benefits

Enables safe bulk restore operations using piped input:

PowerShell> Get-PnPRecycleBinItem | Restore-PnPRecycleBinItemShow

examples:

Get-PnPRecycleBinItem | Where-Object { $_.Email -eq "johndoe@outlook.com" } | Restore-Pnprecyclebinitem -Force
Get-PnPRecycleBinItem | ? { $_.Email -eq "johndoe@outlook.com" } | Restore-Pnprecyclebinitem -Force

  • Avoids triggering LVT errors by skipping unnecessary collection access.
  • Preserves existing behavior for single-item restores when Identity.Item is null.

Limitations

This is a client-side workaround; increasing or bypassing LVT constraints is not feasible as they are enforced server-side to protect backend performance.
The fix does not alter public API surface or expose internal identifiers.

@gautamdsheth gautamdsheth merged commit 8922dca into pnp:dev Sep 27, 2025
3 checks passed
@gautamdsheth
Copy link
Collaborator

Thanks @irvcov , merged it. Much appreciated this fix ! It will be available in tomorrow's nightly builds as well as next major version when we release it.

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.

2 participants