CloudOffice365

How to get all the items in SharePoint recycle bin using PowerShell PnP.Online

How to get all the items in SharePoint recycle bin using PowerShell PnP.Online

To retrieve a list of deleted items in SharePoint using PnP PowerShell, you can follow these steps:

  1. Install the PnP PowerShell module if you haven’t already. You can install it by running the following command in PowerShell:
Install-Module -Name SharePointPnPPowerShellOnline
  1. Open PowerShell and connect to your SharePoint site using the
    Connect-PnPOnline

    cmdlet. Run the following command and enter your site URL and credentials when prompted:

Connect-PnPOnline -Url "https://your-site-url" -UseWebLogin

Replace “https://your-site-url” with the URL of your SharePoint site.

Below is an example for the URL

Connect-PnPOnline -Interactive -Url https://choresor.sharepoint.com/sites/test

Here’s is the command to retrieve all items from the SharePoint recycle bin within a specific date range:

Get-PnPRecycleBinItem | ?{ ($_.DeletedDate -ge '2023-06-30 00:01' -and $_.DeletedDate -le '2023-06-30 23:59') } | Export-Csv -NoTypeInformation -Path .\deletedreport.csv

The below command will get everything from the recycle bin and exports all the data into a .csv file. the report will be located in the same where you run the command. let’s say you run the script in c:\temp directory then it would create a report.csv file in the c:\temp folder.

Get-PnPRecycleBinItem | Export-Csv -NoTypeInformation -Force -Path .\report.csv

 

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button