Delete Folder in SharePoint using PowerShell

July 3, 2020 | by iaur | posted as Administration, SharePoint Online

Sample: Need to delete General folder in Group site named TestKen

Machine generated alternative text:
SharePoint 
Test Ken 
Private group 
Home 
Conversations 
Documents 
Shared with us 
Notebook 
Site contents 
Recycle bin 
New 
Upload 
Quick edit 
Documents 
Name 
Search this library 
Export. to Excel 
Modified 
February 12 
Power Apps 
Modified By 
Bernie Fernandez
  1. Run the ff. using  Windows Powershell
Set-ExecutionPolicy Unrestricted
$User = “admin@faceresionem.onmicrosoft.com
$PWord = ConvertTo-SecureString -String “password” -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
Install-Module SharePointPnPPowerShellOnline
Connect-PnPOnline -Url https://faceresionem.sharepoint.com/sites/TestKen -Credentials $Credential
Remove-PnPFolder -Name “General” -Folder “Shared Documents” -Force
Disconnect-PnPOnline
Machine generated alternative text:
1 
2 
3 
4 
6 
7 
8 
9 
10 
11 
12 
Instal I-Module Sharepoi ntpnppowershel lonline 
Connect-pnponline -Url https://faceresionem.sharepoint.com/sites/TestKen -Credenti als Scredential 
# -Folder: Relative path of the location 
# -Name: Name of the folder 
# If parameter 
"-Force" is applied then on the execution of command, it will not ask for confi rmation to delete the Folde 
Remove-PnPF01der 
conn 
pnponl 
C : tem32> 
C : \WINDOWS\system32> 
C : \WINDOWS\system32> 
C : \WINDOWS\system32> 
c: \WINDOWS\system32> I 
-Name "General " 
-Fol der "shared Documents" 
-Force 
Install -Module Sharepointpnppowershel Ion line 
Connect-pnponline -Url https://faceresionem.sharepoint.com/sites/TestKen 
Remove-PnPF01der -Name 'General" -Folder "Shared Documents" -Force 
Di sconnect-pnponl i ne 
-Credentials Scredential
  1. To check
Machine generated alternative text:
Apps 
o 
Microsoft 365 admi... 
ECP 
D nrtRI 
SharePoint 
Test Ken 
Private group 
Home 
Conversations 
Documents 
Shared with us 
Notebook 
Site contents 
Recycle bin 
New 
Upload 
Quick edit 
Documents 
Name 
Search this library 
Export. to Excel 
Modified 
Power Apps 
Modified By 
Automate v 
Add colur

From:<https://www.c-sharpcorner.com/blogs/permanently-delete-folder-from-sharepoint-library-using-pnp-powershell>

 <https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps#installation>

<https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/remove-pnpfolder>

Feedback or Help?

Should you have one, click here

Boring Ads. Pardon me :)