0

I have multiple OneNote inside site assets library. I want to delete the one note which is created on my name. I am using SharePoint online sites I want to delete it using PowerShell. pls some one help with this.

2 Answers 2

0

According to my research, we cannot delete OneNote notebooks in SharePoint Online through PowerShell.

We can only manually delete OneNote notebooks from the Site Assets library.

1
  • finally i have written code to do this.
    – Liz
    Jul 15, 2021 at 14:49
0
Connect-PnPOnline -url "" -SPOManagementShell
    #$Web = Get-PnPWeb 
    #$Title = $Web.Title
    $Title = $SiteCollection.dSiteName.Replace('/','-') + " " + "Notebook"
    $AuthorEmail = ""
    $Documents = ""

    $ListItems = Get-PnPListItem -List $Documents -PageSize 500 | where {($_.FieldValues.Author.Email -eq $AuthorEmail) -and ($_.FieldValues.ProgId -eq "OneNote.Notebook")}
    #$ListItems = Get-PnPListItem -List $Documents -PageSize 500 | where {($_.FieldValues.Author.Email -eq $AuthorEmail) -and ($_.FieldValues.ProgId -eq "OneNote.Notebook") -and ($_.FieldValues.FileLeafRef -eq $Title)}  
    $FileName = $ListItems["FileLeafRef"] 
    Write-Host $FileName
    Write-Host $ListItems.Id

   Remove-PnPListItem -List $Documents -Identity $ListItems.Id -Force
    if($FileName -eq $Title)
    {
    
    Remove-PnPListItem -List $Documents -Identity $ListItems.Id -Force
    Write-Host "OneNote is Deleted" -ForegroundColor Green  
    }

    else{
    Write-Host "OneNote cannot be found"
}
    
2
  • HI Liz. Thanks for your sharing, you can accept your answer as answer. The behavior will help others who meet the similar issue in the future quickly find the correct answer. Jul 16, 2021 at 8:36
  • Yes i marked this as answered.
    – Liz
    Jul 20, 2021 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.