Recover OneNote

Roger Roger 4,956 Reputation points
2021-02-17T03:07:49.643+00:00

Hi All

One of my user has lost onenotes, how do i recover them using powershell. i.e if deleted onenotes are in onedrive recyclebin can i restore the
onenotes using powershell. Is it possible to export the contents of onedrive recyclebin to a csv file.

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,236 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,745 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,211 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,138 questions
0 comments No comments
{count} votes

Accepted answer
  1. Echo Du_MSFT 17,116 Reputation points
    2021-02-17T09:39:04.5+00:00

    Hello @Roger Roger ,

    You could run the following PnP PowerShell script to export all the deleted content details in OneDrive Recycle Bin :

    #Get the PnP PowerShell module  
    Install-Module SharePointPnPPowerShellOnline  
      
    #Config Variables  
    $SiteURL = "https://****-my.sharepoint.com/personal/username_****_onmicrosoft_com"  
      
    #Connect to PnP Online  
    Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)  
      
    #Get Recycle bin Items  
    Get-PnPRecycleBinItem | Select Title, ItemType, Size, ItemState, DirName, DeletedByName, DeletedDate | Format-table -AutoSize  
      
    #Export results to CSV  
    #This is the path where you want to export this file  
    Get-PnPRecycleBinItem | Export-Csv C:\Temp\OneDrive_RecycleBin.csv   
    

    68978-3.png
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    69044-5.png

    I provide the following PowerShell commands to restore OneNote:

    #Restore Recycle Bin Item by ID  
    Restore-PnPRecycleBinItem -Identity "768869c5-d3db-46e7-ad80-f5342b81b8c1" -Force  
      
    #Restore Recycle Bin Item by ItemType  
    Get-PnPRecycleBinItem | Where {$_.ItemType -eq "Folder"} | Restore-PnpRecycleBinItem -Force  
    

    69071-6.png

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    69072-7.png

    Thanks,
    Echo Du

    ======================

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Roger Roger 4,956 Reputation points
    2021-02-17T15:18:48.73+00:00

    Thanks, how do i export one drive items to csv file.

    0 comments No comments