Sharepoint powershell loop all site collection, sites, sub sites

[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) > $null

 

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local

$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}

$webapps = @()

 

foreach ($websvc in $websvcs)

{

write-host “###############Web Applications################”

foreach ($webapp in $websvc.WebApplications)

{

write-host “Webapp Name :”$webapp.Name “Webapp URL :”$webapp.URL “UI Version :” $webapp.UIVersion

write-host “#############Site Collections###############”

foreach ($site in $webapp.Sites)

{

write-host “Site Name :”$site.Name “Site URL :”$site.URL “UI Version :” $site.UIVersion

write-host “#################Websites################”

foreach ($web in $site.AllWebs)

{

write-host “Web Name :”$web.Name “Web URL :” $web.URLĀ  “UI Version :” $web.UIVersion

}

}

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami