Users get creative and sometimes happen to accidentally delete items, files, and even lists. Office 365 allows for several options to deal with such situations, including restore from recycle bin or restore from backups after contacting MS Support. One of the many options that SharePoint Online offers is the ability to hide the delete button from list settings:

 


Using UI

 

Using UI you can remove users' permissions to achieve similar effect:

 

List Permissions
Manage Lists  -  Create and delete lists, add or remove columns in a list, and add or remove public views of a list.

 

Using CSOM

 

SharePoint Online SDK allows to modify list properties. The property responsible for the "delete this document library" button visibility is called AllowDeletion and takes boolean values.

 

1. Add SharePoint Online SDKs. You can find a Nuget package here:
# Paths to SDK. Please verify location on your computer.
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

 

2. Create context that allows connection to a particular site collection or subsite and test this connection:

 

$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username$AdminPassword)
 
  try
  {
      $ctx.ExecuteQuery()
  }
  catch [Net.WebException]
  {           
      Write-Host $Url " failed to connect to the site" $_.Exception.Message.ToString() -ForegroundColor Red
  }


3. Load the list where you want to update the AllowDeletion property:

 

$ctx.Load($ctx.Site)
$lista=$ctx.Web.Lists.GetByTitle($ListTitle)
$ctx.Load($lista)
$ctx.ExecuteQuery()

4. Change the AllowDeletion property and update the list:
$lista.AllowDeletion = $false
$lista.Update()
$ctx.ExecuteQuery()

 

End effect

 



Other Languages


Office 365 Datenschutz: verhindern das Löschen der SharePoint-Liste (de-DE)

 

References


Web
Analytics