Forum Discussion

SAURAV KUMAR's avatar
SAURAV KUMAR
Copper Contributor
Mar 12, 2022

Need to remove one drive folder using PnP Powershell

Hi Team,
I'm trying to remove a folder using PnP and its throwing error as 404 Not Found, commands i am using as below

Connect-PnPOnline -Url "onedrive Url" - credential (Get-Credential)

$name = "Nest1"

$Folderpath = "Document\Nest1"

Remove-PnPFolder -Name $name -Folder $Folderpath - Force -Recycle

Thank you for your help

Regards
Saurav
  • SvenSieverding's avatar
    SvenSieverding
    Bronze Contributor
    Are you trying to delete the folder "Document\Nest1" or "Document\Nest1\Nest1"?

    This Powershell script tries to delete "Document\Nest1\Nest1"....

    If you want to delete "Document\Nest1" then try
    Remove-PnPFolder -Name "Nest1" -Folder "Document" - Force -Recycle
    • pk_Tech's avatar
      pk_Tech
      Copper Contributor
      Hi ,

      I have run same command but getting the error message

      Remove-PnPFolder -Name "lab_November" -Folder "Document" -Force -Recycle
      Error Message: Remove-PnPFolder : The remote server returned an error: (403) Forbidden.

Resources