The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Is here someone else that is willing to help me today?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
SharePoint PnP PowerShell script for restoring a lot! of deleted items from Recycle Bin
The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Is here someone else that is willing to help me today?
Hi Ruby,
Is it possible for us to to connect today and walk though your questions so that I can finalize my restore of all my deleted files in my recycle bin?
Thank you,
[Moderator note: Personally Identifiable Information removed]
Hi Ruby, your questions are technical in nature to me and hard to understand some of them. Here is a snip of my current issue. We can run, Get-PnPRecycleBinItem . I was told to tell you I need to restore bulk files from recycle bin through pnp PowerShell commands.
Does this help?
Good day Eric,
Just to gently clarify before going any further, this forum is separate from Microsoft Support. I don’t have the ability to access or investigate individual accounts because this is a user‑to‑user support forum.
To help me better understand the situation and assist you effectively, could you please share a few details such as:
1/ What is the full error message?
2/ Which PowerShell version and PnP.PowerShell version are you using?
3/ Does your account have Site Owner or Site Collection Administrator permissions on the affected SharePoint site?
4/ Are the deleted items located in the first stage or second stage Recycle Bin?
This will help me better understand the context and provide more targeted support. Any additional information will help me better understand and support you.
To help identify the cause, please check the options below:
Option 1: Check your PnP PowerShell environment
Open PowerShell 7 and run:
$PSVersionTable.PSVersion
PnP PowerShell requires PowerShell 7.4 or later. If needed, run the following commands one at a time:
Install-Module PnP.PowerShell
Update-Module PnP.PowerShell
Import-Module PnP.PowerShell
Then reopen PowerShell and test the script again.
Option 2: Verify the connection
Connect to the SharePoint site using your Microsoft Entra app Client ID:
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive -ClientId "your-app-client-id"
After signing in, run:
Get-PnPConnection
This confirms that you are connected to the intended site.
Option 3: Confirm your permissions
Note: In case you do not know who is your IT admin, kindly refer to this article: How do I find my Microsoft 365 admin? - Microsoft Support
If you have the required permissions, please try restoring a small number of items first to confirm the process works as expected.
Option 4: Use the SharePoint interface as a workaround
If the script still doesn't run, a site administrator can restore the items directly from SharePoint:
Additional information is available in the following resource: Restore deleted items from the site collection recycle bin - SharePoint in Microsoft 365 | Microsoft Learn
The following PnP references provide more details and examples:
Installing PnP PowerShell | PnP PowerShell
Register an Entra ID Application to use with PnP PowerShell | PnP PowerShell
Get-PnPRecycleBinItem | PnP PowerShell
Restore-PnPRecycleBinItem | PnP PowerShell
Restore large amount of items from SharePoint Recycle bin in bulk | PnP Samples
Note: These links are shared by community members for your convenience. They point to third-party websites that aren't managed, maintained, or verified by Microsoft. I cannot guarantee the quality, safety, or suitability of any content or software available on those sites. Please review the information carefully and ensure you understand any potential risks before using it.
If you have any questions, please don’t hesitate to reach out at any time.
Thank you for your patience and understanding.
If you have any extra questions about this answer, please click "Comment".