Sometimes small requirements take more time.

My colleague wanted to get all the sites that a web application has and to store it in an Excel file.

After spending the whole day he finally came to me and asked me to help him with a script and subsequently publish it.

So here is the code.

This code will provide you the following fields in an Excel file:

  1. Site’s Title
  2. Url
  3. Site’s ID
  4. Parent Web ID

Code

Get-SPWebApplication My web app here | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, ParentWebID | Export-CSV FileLocationHere\File.csv –NoTypeInformation.

Keep Learning ,
Cheers.