Wednesday, 11 July 2018

SharePoint 2013: Get the Orphaned Site Collection using powerShell




if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{Add-PSSnapin Microsoft.SharePoint.Powershell}

$OrpCnt =  Get-SPContentDatabase

ForEach ($Orp in $OrpCnt)
{   

      $Sts = Get-SPWebApplication -Limit All | Get-SPSite
      Write-Host "Detecting Orphans for " $Orp.Name  $Sts.Name  $Orp.Repair($false
}

Get-SPWebApplication -Limit All | Get-SPSite | Format-Table -Property URL,ContentDatabase

No comments:

Post a Comment