The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
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
- The account running the script must be a Site Collection Administrator or Site Owner on the target site.
- If your account doesn't have the required permissions, I recommend contacting the site owner or your organization's IT administrator and asking them to assign the appropriate role. Once the permissions are updated, reconnect and test the script again.
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:
- Open the affected SharePoint site > Open Recycle Bin > Select the items you want to restore > Select Restore.
- If the items are in the second stage Recycle Bin, open Second-stage Recycle Bin from the bottom of the page and restore them there.
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".