Pages

Nov 28, 2011

Sharepoint 2007 - Poweshell Script to Delete site.


[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Sharepoint”)
$site = New-Object Microsoft.SharePoint.SPSite("http://md1devvmossapp3:15801/")
foreach ($web in $site.AllWebs) {
  try
{
  $web.Delete()   
  $web.Dispose()
  Write-Host $web.Url " : Is deleted"
  }
  catch [System.SystemException]
{
    write-host “Execution stopped due to: “+$_.Message
}
}


Reference : 

No comments: