PowerShell List of SharePoint sites, output to text file
Here is a simple and quick powershell script to enumerate all the sub sites in SharePoint and output the results to a text file
[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 = @()
#$List = @()
foreach ($websvc in $websvcs)
{
foreach ($webapp in $websvc.WebApplications)
{
foreach ($site in $webapp.Sites)
{
write-host $site.URL
foreach ($web in $site.AllWebs)
{
write-host $web.URL “,” $web.TITLE
$web.URL + “,” + $web.TITLE | out-file -filepath C:\list_of_sites.txt -append
}
}
}
}
go
Here is a simple and quick powershell script to enumerate all the sub sites in SharePoint and output the results to a text file
[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 = @()
#$List = @()
foreach ($websvc in $websvcs)
{
foreach ($webapp in $websvc.WebApplications)
{
foreach ($site in $webapp.Sites)
{
write-host $site.URL
foreach ($web in $site.AllWebs)
{
write-host $web.URL “,” $web.TITLE
$web.URL + “,” + $web.TITLE | out-file -filepath C:\list_of_sites.txt -append
}
}
}
}
go