当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] SharePoint Online:“删除此文档库”缺失!

作者:精品下载站 日期:2024-12-14 14:53:36 浏览:13 分类:玩电脑

SharePoint Online:“删除此文档库”缺失!


问题:无法删除 SharePoint Online 文档库,因为文档库设置中缺少“删除此文档库”选项!

我尝试从网站内容页面、库的功能区菜单、SharePoint Designer、内容和结构工具、资源管理器视图和 PowerShell 中删除库,但没有任何帮助!

解决方案:

如果您在 SharePoint Online 网站上没有“编辑”或更多访问权限,您可能看不到“删除此列表”选项!此外,在某些系统库中,“允许删除”标志被设置为“FALSE”,以防止库被意外删除。 (例如,在“Farm Templates”、“Style Library”等中,默认缺少删除此文档库链接以防止删除)。

[玩转系统] SharePoint Online:“删除此文档库”缺失!

如何在 SharePoint Online 文档库中启用删除功能?

使用此 PowerShell 通过将“允许删除”标志设置为 True 来启用库中的删除!


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
 
#Set parameter values
$SiteURL="https://Crescent.sharepoint.com/"
$LibraryName="AppAssets"

Try {
    #Get Credentials to connect
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
  
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials
 
    #Get the Document Library and set allow deletion flag
    $Library=$Ctx.Web.Lists.GetByTitle($LibraryName) 
    $Library.AllowDeletion = $True
    $Library.Update()
    $Ctx.ExecuteQuery()
             
    #Delete the Document Library (Send to Recycle bin)
    $Library.Recycle() | Out-Null
    $Ctx.ExecuteQuery()
 
    Write-Host "Document Library: '$LibraryName' has been Deleted Successfully!" -ForegroundColor Green  
}
Catch {
    write-host -f Red "Error Deleting Document Library!" $_.Exception.Message
}

使用 PnP PowerShell 也可以实现同样的效果:


#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/pmo"
$ListName = "Projects"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get the List
$List = Get-PnPList -Identity $ListName
 
#Enable Delete option for the list
$List.AllowDeletion = $True
$List.Update()
Invoke-PnPQuery

这使得可以删除文档库。要使用 PowerShell 删除 SharePoint Online 中的文档库,请参阅我的另一篇文章:SharePoint Online:使用 PowerShell 删除文档库

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯