powershell 此递归PowerShell脚本从SharePoint中删除网站及其所有子网站。这消除了无法进行del的问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 此递归PowerShell脚本从SharePoint中删除网站及其所有子网站。这消除了无法进行del的问题相关的知识,希望对你有一定的参考价值。

function RemoveSPWebRecursively([Microsoft.SharePoint.SPWeb] $web)
{
    Write-Debug "Removing site ($($web.Url))..."
    
    $subwebs = $web.GetSubwebsForCurrentUser()
    
    foreach($subweb in $subwebs)
    {
        RemoveSPWebRecursively($subweb)
        $subweb.Dispose()
    }
    
    $DebugPreference = "SilentlyContinue"
    Remove-SPWeb $web -Confirm:$false
    $DebugPreference = "Continue"
}

$DebugPreference = "SilentlyContinue"
$Site = 'http://portal.opwftg.com/sites/OPWSS/Teams/Safety/InternationalSafety/Fibrelite2/Cells'
$web = Get-SPWeb $Site
$DebugPreference = "Continue"

If ($web -ne $null)
{
    RemoveSPWebRecursively $web
    $web.Dispose()
}

以上是关于powershell 此递归PowerShell脚本从SharePoint中删除网站及其所有子网站。这消除了无法进行del的问题的主要内容,如果未能解决你的问题,请参考以下文章