[SPO] Delete document library folder and its contents using PNP PowerShell (V2)

OK, so these days one of my site’s visitors (thanks Alice) mentioned that my previous script to delete document library folder contents using PNP from [ here ] is only deleting files and folders cannot be deleted anymore when using PnP.PowerShell 1.10.0.

The exception when trying to remove a folder with the script is: Remove-PnPFolder : Server relative urls must start with SPWeb.ServerRelativeUrl 

True that the script worked with PnP.PowerShell 1.9.0.

That being said, I rebuilt a new script:

Note: the above script completely deletes the document library folder.

In case you want to “move” the folder to the recycle bin instead, use the following script:

Enjoy!