Get all Site Collections, Sites & Sub Sites form Web Application in SharePoint 2010 using Powershell

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.

  • You have to change the web application and the location of your Excel file you want to generate.
  • Save it as a .ps1 file and store it to your location.

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.

  • Click on Start

  • Under Microsoft SharePoint 2010 Products you have SharePoint 2010 Management Shell.

  • Right-click on it and select Run as administrator.

  • Run the following ps1 file and you will get the output generated in an Excel file.

  • You have the output

Keep Learning ,
Cheers.

Ebook Download
View all
Learn
View all