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

[玩转系统] SharePoint Online:使用 PowerShell 删除投放库

作者:精品下载站 日期:2024-12-14 14:37:24 浏览:17 分类:玩电脑

SharePoint Online:使用 PowerShell 删除投放库


要求:删除 SharePoint Online 中的投放库。

网站所有者激活了网站中的“内容管理器”功能,将“投放库”引入了 SharePoint Online 网站。现在,当他尝试通过库设置删除此库时,他在库设置中找不到“删除此文档库”链接!停用内容管理器功能没有帮助。那么,如何从 SharePoint Online 中删除投递库呢?

[玩转系统] SharePoint Online:使用 PowerShell 删除投放库

由于drop-off库没有提供“删除这个库”链接,我们必须使用PowerShell来删除这个库。

SharePoint Online 使用 PowerShell 删除删除库

投递库通过内容组织器功能自动将文档路由到网站上的适当位置。一旦该功能被停用,我们可以通过设置:AllowDeletion属性来删除Drop Off Library。以下是用于删除 SharePoint Online 中的投放库的 PowerShell 脚本:


#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"
   
##Variables for Processing
$SiteUrl = "https://Crescent.sharepoint.com/DocCenter"

Try { 
    #Get Credentials to connect
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
  
    #Set up the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
    $Ctx.Credentials = $credentials
   
    #Get the Drop Off Library
    $Library = $Ctx.web.Lists.GetByTitle("Drop Off Library")

    #Set Allow Deletion Property
    $Library.AllowDeletion = $True
    $Library.Update()

    #Delete the Library
    $Library.DeleteObject()
    $Ctx.ExecuteQuery()

    Write-Host -f Green "Drop Off Library Deleted Successfully!"
}
Catch {
    write-host -f Red "Error Deleting Drop Off Library!" $_.Exception.Message
}

PnP PowerShell 用于删除 SharePoint Online 中的 Drop-OFF 库

您还可以使用 PnP PowerShell 删除 drop-off 库:


#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Projects/"
$LibraryName="Drop Off Library"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
 
#Get the Library to Delete
$Library = Get-PnPList -Identity $LibraryName -ErrorAction SilentlyContinue
 
#Check if Library exists
If($Library)
{
    #Allow Deletion
    $Library.AllowDeletion = $True
    $Library.Update()
    Invoke-PnPQuery
 
    #delete library in sharepoint online powershell
    Remove-PnPList -Identity $LibraryName -Recycle -Force
    Write-host -f Green "Library '$LibraryName' Deleted Successfully!"
}
Else
{
    Write-host -f Yellow "Could not find Library '$LibraryName'"
}

在本文中,我们讨论了如何删除 SharePoint Online 中的投放库。通过遵循本指南中概述的步骤,您可以快速轻松地删除投放库,以减少 SharePoint Online 环境中的混乱。

在 SharePoint 本地部署中,您还可以通过将“AllowDeletion”设置为“True”来删除任何文档库或列表,如我的另一篇文章:如何使用 PowerShell 删除 SharePoint 中的任何文档库或列表?

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

取消回复欢迎 发表评论:

关灯