SharePoint List all Sites and Subsites of a webapplication using powershell

There might be one day when you think you need a list of all sites and subsites and sub-subsites of one of your web application. Well you can do this by code or by powershell. I prefer powershell as long as you have access to the server.

Well, the script below needs a webapplication url. For this url it runs through each site collection and fetches of each site collection the subsites and their subsites.



## SharePoint DLL
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$webApplicationURL = Read-Host "Enter Web application"

$webApp = Get-SPWebApplication $webApplicationURL

if($webApp -ne $null)
{
#Write-Host "Web Application : " + $webApp.Name
foreach($siteColl in $webApp.Sites)
{
if($siteColl -ne $null)
{
Write-Host -foregroundcolor red "Site Collection: "$siteColl.Url
Get-SPSite $siteColl | Get-SPWeb -Limit All | Select Title, Url
}
else
{
Echo $siteColl "does not exist"
}
}
}
else
{
Write-Host  $webApplicationURL "does not exist, check the WebApplication name"
}


I am sure you might need it some day.

..:: I LIKE SHAREPOINT ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Pohnke About Karsten Pohnke
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

1 comment on “SharePoint List all Sites and Subsites of a webapplication using powershell

  1. Pingback: SharePoint List all Sites and Subsites of a webapplication using powershell – ..:: I like SharePoint ::.. | SPOmani

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.