2

I'm trying to delete the home library as it is not needed anymore. Unfortunately, there isn't a 'delete library' option under the permissions section. Does anyone know how to delete this library? I have tried the following (see screenshot):enter image description here

Hopefully, I'm doing something wrong.

2 Answers 2

1

Please see below your updated PowerShell code to delete library

SharePoint On-premises

$web = Get-SPweb "Site Url"
$list = $web.Lists["Documents"]
$list.AllowDeletion =$true
$list.Update() 
$list.Delete()

Office 365

$SiteUrl = "Site Url"
$Cred = Get-Credential
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$ctx.Credentials = $Credentials
$ctx.Load($ctx.Web)
$ctx.ExecuteQuery()

$list=$ctx.Web.Lists.GetByTitle("Documents")
$ctx.Load($list)
$ctx.ExecuteQuery()

$list.AllowDeletion = $true
$list.Update()
$ctx.ExecuteQuery()

$list.DeleteObject()
$ctx.ExecuteQuery()

Note: For Office 365 you need SharePoint Online Management Shell install on your machine. That you can download from below link

SharePoint Online Management Shell

1
  • I got it to work. Thanks again!
    – Lando
    Apr 9, 2019 at 17:23
0

Looks like you are using SharePoint Online.

In this case, you can use the PnP PowerShell to interact with SPO and perform operations.

Simply install the module as below:

Install-Module SharePointPnPPowerShellOnline

After that, you can delete the list as below:

Connect-PnPOnline -Url "<https://site-collection-url>"
Remove-PnPList -Identity Documents -Force

References - PnP-PowerShell

Remove-PnPList

Your Answer

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

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