Sun. Sep 22nd, 2019

Samir Daoudi's Technical Blog

SharePoint, Office 365, C#, .Net, SQL Server News, Tips, Ebooks, Events, Webinars ….etc

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 harePoint") > $null harePoint $websvcs = $farm harePoint #$List = @() ites)

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

Leave a comment

Show Buttons
Hide Buttons
%d bloggers like this: