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

[玩转系统] 使用 PowerShell 强制删除 SharePoint 中损坏的网站集

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

使用 PowerShell 强制删除 SharePoint 中损坏的网站集


今天SharePoint 2013环境中出现了一个奇怪的问题!通过自定义代码配置的网站集之一无法访问,并出现“404 页面未找到”错误。但是,该特定网站列在中央管理 >> 查看所有网站集下!但管理中心的网站集没有提供更多详细信息,例如内容数据库等。

我们得出的结论是该网站集“已损坏!”。在许多情况下,站点可能会损坏,例如:存储介质故障、网络连接问题、PowerShell cmdlet 的错误使用(例如,如果您使用不带“DestinationDatabase”参数的 Copy-SPSite,您最终会出现损坏的网站!)等。

因此,我们尝试从 SharePoint 中央管理中删除网站集,但 SharePoint 中央管理不允许我选择和删除该网站。我尝试了 STSADM -o DeleteSiteRemove-SPSite PowerShell cmdlet 没有运气!

Stsadm 和 PowerShell 方式导致错误:0x80070003

[玩转系统] 使用 PowerShell 强制删除 SharePoint 中损坏的网站集

[玩转系统] 使用 PowerShell 强制删除 SharePoint 中损坏的网站集

解决方案:如何删除 SharePoint 中损坏的网站集?

我们可以通过以下方法使用 STSADM 或 PowerShell 删除损坏的网站集。

STSADM 删除损坏的网站集:
第 1 步: 我们需要需要删除的网站的网站 ID、数据库服务器、数据库名称参数。运行:

stsadm -o EnumAllWebs > SitesList.xml

这会生成一个 XML 文件,其中包含网站集 ID、内容数据库、数据库服务器等详细信息,如下所示。

[玩转系统] 使用 PowerShell 强制删除 SharePoint 中损坏的网站集

步骤 2:提取所需的参数值并将其提供给 STSADM -o DeleteSite,如下所示:

stsadm -o deletesite -force -siteid “1252fd8f-a0ea-4ef9-9b66-4715f8e44b37” -databaseserver SP13-Ent-SQL01 -databasename SP13_Intranet_Content

[玩转系统] 使用 PowerShell 强制删除 SharePoint 中损坏的网站集

同样的方法也适用于损坏的网站(Web)。例如:
stsadm -o deleteweb -force -webid -databasename -databaseserver

使用 PowerShell 删除损坏的网站集:

使用此 PowerShell 脚本删除 SharePoint 中损坏的网站集。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$CorruptedSiteURL ="https://intranet.crescent.com/sites/sales"

#Get the site collection
$site = Get-SPSite $CorruptedSiteURL

#Get the GUID of the site collection
$siteGUID = $site.Id
Write-host "Site collection GUID:"$siteGUID

#Get the content Database of the Site collection
$siteDatabase = $site.ContentDatabase 

#Force delete the site collection
$siteDatabase.ForceDeleteSite($siteGUID, $false, $false)

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

取消回复欢迎 发表评论:

关灯