Enumerating Sites in a farm

Use the following one liner to enumerate the sites and subsites in a SharePoint 2010 or 2013 web application:

Get-spwebapplication (url to web app) | get-spsite -limit all | get-spweb  -limit all  | format-table name, url -auto -wrap

 

If you wanted to pipe that to a file, you could use Out-File, followed by a path to your file, e.g.

Get-spwebapplication (url to web app) | get-spsite -limit all | get-spweb  -limit all  | format-table name, url -auto -wrap | Out-File -filepath c:\PathToMyFile\NameOfMyFile.txt

 

if you wanted to run this on a weekly basis, you could do something like this, and add it to a ps1 file. then call it from a scheduled task.

$file="e:\Prodwebs.txt"


Get-date | out-file $file append


Get-spwebapplication http://mdcpappshr02wv | get-spsite -limit all | get-spweb  -limit all  | format-table  url -auto -wrap | out-file $file  -append


Get-spwebapplication http://mdcpappshr02wv:8078 | get-spsite -limit all | get-spweb  -limit all  | format-table  url -auto -wrap | out-file $file  -append


Get-spwebapplication http://mdcpappshr02wv:8080 | get-spsite -limit all | get-spweb  -limit all  | format-table  url -auto -wrap | out-file $file  -append