logo
search
Deleted File Recovery

How to Bulk Restore SharePoint Recycle Bin Files Using PowerShell

Maira MehtabMaira Mehtab Sep 21, 2026 869 views

Question details

The user needs to recover thousands of deleted files from a SharePoint site's recycle bin but encounters a command-not-found error when attempting to run Connect-SPOService.

Product
SharePoint Online / PowerShell
Device & OS
not provided
Scenario
Attempting to perform a bulk recovery of accidentally deleted items from a SharePoint recycle bin using PowerShell scripts.
Observed behavior
Running the Connect-SPOService cmdlet returns a 'command not found' error, completely blocking the execution of the restore operation.
Before you start

Verify that you have SharePoint Administrator privileges and that your PowerShell execution policy allows the installation of remote modules.

Solution 1Recommended

Install the SharePoint Online Management Shell

Resolve the 'Connect-SPOService' command-not-found error by installing the official SharePoint Online PowerShell module.

The command-not-found error typically indicates that your local PowerShell environment lacks the Microsoft.Online.SharePoint.PowerShell module. This must be installed before you can connect to your tenant.

1
Open PowerShell as Administrator

Search for Windows PowerShell in your Start menu, right-click the application, and select 'Run as administrator'.

2
Install the Required Module

Type the command 'Install-Module -Name Microsoft.Online.SharePoint.PowerShell' and press Enter. If prompted to trust the repository, type 'Y' and accept.

3
Connect to SharePoint Services

Once installed, try running 'Connect-SPOService -Url https://[yourtenant]-admin.sharepoint.com' again. Log in with your admin credentials when the authentication window appears.

Native Limitations: The default module may not include a single command for bulk restoration. You will likely need to write a custom loop script to iterate through the recycle bin items.
Free Microsoft Office alternative

Streamline Your Document Management with WPS Office

While recovering deleted SharePoint infrastructure requires advanced tools like PowerShell, creating and editing your daily documents shouldn't be complicated. WPS Office is a highly compatible, free alternative to Microsoft Office that offers a familiar interface, lightweight installation, and powerful built-in local backup tools to help prevent data loss in the first place.

  1. 1. Download and Install: Get the official free WPS Office installer from the WPS website and complete the swift installation process.
  2. 2. Open Restored Files: Once your SharePoint files are restored, sync them to your desktop and simply double-click them to edit seamlessly in WPS Office.
  3. 3. Enable Local Backup: Go to WPS Office settings and configure auto-backup intervals to ensure you never lose document progress, even if cloud sync fails.
Seamless compatibility with Microsoft Office file formats (.docx, .xlsx, .pptx).Built-in robust local backup and document recovery features to prevent accidental file loss.Lightweight application footprint resulting in extremely fast startup times.All-in-one tabbed workspace for managing documents, spreadsheets, and PDFs efficiently.
microsoft office alternative - wps office

Frequently Asked Questions

Why is the Connect-SPOService command missing on my PC?

This happens when the Microsoft SharePoint Online Management Shell is not installed in your PowerShell environment. You must download it from Microsoft or run 'Install-Module -Name Microsoft.Online.SharePoint.PowerShell' to add the necessary cmdlets.

Is there a native SharePoint cmdlet that restores the entire recycle bin instantly?

No, the standard SharePoint Online module does not have a single 'restore all' cmdlet. Administrators usually have to write a looping script using 'Get-SPODeletedSite' or rely on the PnP PowerShell module to chain 'Get-PnPRecycleBinItem' into 'Restore-PnPRecycleBinItem'.

How long are deleted files kept in the SharePoint recycle bin?

SharePoint retains deleted files for a total of 93 days. If they are removed from the user's first-stage recycle bin, they are held in the second-stage (site collection) recycle bin for the remainder of that 93-day window before permanent deletion.

Do I need Global Administrator rights to use PnP PowerShell?

Not necessarily. While tenant-level actions require Global or SharePoint Administrator roles, you can use PnP PowerShell to restore recycle bin items within a specific site if you hold Site Collection Administrator privileges for that site.