unable to run pnp powershell script

Eric Barber 0 Reputation points
2026-10-21T17:50:49.5633333+00:00

SharePoint PnP PowerShell script for restoring a lot! of deleted items from Recycle Bin

Microsoft 365 and Office | SharePoint | Development
0 comments No comments

4 answers

Sort by: Most helpful
  1. Eric Barber 0 Reputation points
    2026-10-22T18:34:41.0566667+00:00

    Is here someone else that is willing to help me today?

    Was this answer helpful?


  2. Eric Barber 0 Reputation points
    2026-10-22T13:20:29.2766667+00:00

    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] 

    Was this answer helpful?


  3. Eric Barber 0 Reputation points
    2026-10-21T19:09:12.8966667+00:00

    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?

    User's image

    Was this answer helpful?


  4. Ruby Nguyen 3,640 Reputation points Independent Advisor
    2026-10-21T18:46:10.3266667+00:00

    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".            

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.