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

[玩转系统] 删除网站“Site-URL”时出现问题。无法删除具有子网站或某些应用程序的网站。请删除所有子网站并删除应用程序后重试。

作者:精品下载站 日期:2024-12-14 14:34:04 浏览:15 分类:玩电脑

删除网站“Site-URL”时出现问题。无法删除具有子网站或某些应用程序的网站。请删除所有子网站并删除应用程序后重试。


问题:如果您尝试删除其中包含子网站的 SharePoint Online 网站,SharePoint 会抛出一条错误消息,提示
“出现问题删除网站“”。无法删除具有子网站或某些应用程序的网站。请删除所有子网站并删除应用程序后重试。“

[玩转系统] 删除网站“Site-URL”时出现问题。无法删除具有子网站或某些应用程序的网站。请删除所有子网站并删除应用程序后重试。

解决方案:

基本上,SharePoint Online 告诉我们:您必须先删除所有子网站才能删除其父网站。只需点击几下即可删除子网站:

  1. 导航到子网站>>转到网站设置>>单击网站操作组下的“删除此网站”链接。
  2. 确认一次提示。

    [玩转系统] 删除网站“Site-URL”时出现问题。无法删除具有子网站或某些应用程序的网站。请删除所有子网站并删除应用程序后重试。

但是,当您有大量子网站(例如:50 个!)时,使用浏览器界面删除每个子网站既麻烦又耗时。所以,解决方案就是PowerShell!

使用 PowerShell 删除 SharePoint Online 中的子网站:


#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 Parameters
$SiteURL="https://crescent.sharepoint.com/sites/Ops/us/2017"

#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
         
$Ctx.web.DeleteObject()
$Ctx.ExecuteQuery()
write-host -f Green "Subsite Deleted Successfully "$SiteURL

此 PowerShell 脚本删除给定站点,该站点下面没有子站点。让我们添加一些错误处理代码并将其包装在可重用函数中。以下 PowerShell 脚本递归删除站点及其所有子站点。

SharePoint Online:使用 PowerShell 删除网站及其所有子网站:

以下是用于从 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"

#Get Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Custom Function to Delete a site with subsites
Function SPODelete-Subsite ($SiteURL)
{
    Try { 
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials
        $web = $Ctx.Web
        $Ctx.Load($web)
        #Get all subsites under given site
        $Ctx.Load($web.Webs)
        $Ctx.ExecuteQuery() 
  
        #Loop through each subsite in the current web
        foreach ($SubWeb in $web.Webs)
        {
            #Call the function recursively to delete all subsites under current site
            SPODelete-Subsite($Subweb.url)
        }
 
        #Delete the subsite
        $web.DeleteObject()
        $Ctx.ExecuteQuery()
        write-host -f Green "Subsite Deleted Successfully "$SiteURL
        }
    Catch {
        write-host -f Red "Error Deleting Subsite $($SiteURL)" $_.Exception.Message
    }
}

#Set Parameters
$SiteURL="https://crescent.sharepoint.com/sites/Ops/us"

#Call the function to delete site with subsites
SPODelete-Subsite -SiteURL $SiteURL

这是我关于删除 SharePoint Online 中的子网站的另一篇文章:如何使用 PowerShell 删除 SharePoint Online 中的子网站?

但是,您可以毫无问题地删除根级站点(可能有子站点)!

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

取消回复欢迎 发表评论:

关灯