Finding a file or folder in the SharePoint Online recycle bin can sometimes be like navigating a maze. That's why we've created the PowerShell module "SharePoint.Online.RecycleBin.SearchAndRestore".
Available for download on the PowerShell Gallery.
This module allows you to search, explore, and restore in the SharePoint Online recycle bin using a Windows Forms interface.
Prerequisites :
Windows : This module uses Windows Forms for the user interface display. The module has been tested on Windows 10, 11, 2016, 2019, and 2022 without any compatibility issues.
PNP.Powershell module : The SharePoint.Online.RecycleBin.SearchAndRestore module relies on PNP.Powershell. The 2.2.0 version of PNP.Powershell will be automatically installed during the module installation.
Powershell version 7 : PNP.Powershell requires version 7 of Powershell to operate. If you don't already have it, you can find the latest version of Powershell 7 on GitHub. Go to the Releases section, download the "PowerShell-7.x.x-win-x64.msi" file, and then install it.
Module Installation :
Launch a PowerShell 7 command prompt as an administrator and then type the following command:
Install-Module -Name SharePoint.Online.RecycleBin.SearchAndRestore
The module and its dependencies will be automatically installed.
Module Operation :
In a PowerShell 7 command prompt, type the following command to launch the graphical interface:
Invoke-SharePoint.Online.RecycleBin.SearchAndRestore
Connection :
In the 'SharePoint site URL' field, enter the address of the SharePoint site you wish to connect to, then click on the 'Connect' button:
You will then be prompted with the usual web login window for your Microsoft 365 tenant. Log in as you normally would.
If you have never used the PNP.Powershell module on your tenant, during the first connection, you will need to grant application type access for the PNP.Powershell module to your tenant.
Later on, you can manage the module's permission levels or completely revoke its access via the Azure portal under Azure Active Directory, then Enterprise Applications:
Once connected, the 'Connect' button will be grayed out, and you will see a "Connected" message in green:
Select the date range of deletion:
In the search, the date range you select corresponds to the deletion date of the file or folder.
The 'Start of Date Range' field corresponds to the earliest date, and the 'End of Date Range' field corresponds to the most recent date (default is today's date).
If you're looking for all files and folders deleted between 01/10/2023 and 18/10/2023, here's how you should make your selection (note the use of the * character in the search fields to signify that we are searching for all file or folder names across all locations on the SharePoint site):
Be cautious, the date range is always taken into account in your searches. If you are unsure when the file or folder was deleted, make sure to select a range of several weeks, months, or even years.
Search for a file or a folder :
Searches are based on the 'like' comparison operators of PowerShell, so you can use the syntax of this operator. For a first search, I recommend simply using the * asterisk :
Here are some examples with a file named "file_test_1.xlsx" :
A file whose name ends with ".xlsx" => *.xlsx
A file whose name starts with "file" => file*
A file whose name contains "test_1" => *test_1*
Search by location :
The location corresponds to where the file or folder was before it was deleted and placed in the recycle bin. The 'like' operator is also used here. To search for a specific location, I recommend using just a part of your directory structure.
Here's an example to search for files formerly contained in "folder/subfolder1/subfolder2":
*folder/subfolder1/subfolder2*
Search for a file or folder in a specific location :
You can, of course, combine both search fields to find a file with a specific name in a specific location.
To find the file "file_test_2.pptx" formerly located at "folder/subfolder1/subfolder2":
Restore :
Simply select the files or folders you wish to restore and click on the 'Restore' button:
At the end of the restoration, a summary will be displayed:
コメント