Quantcast
Channel: Powershell – ..:: I like SharePoint ::..
Viewing all articles
Browse latest Browse all 41

SharePoint List all Sites and Subsites of a webapplication using powershell

$
0
0

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 ::..


Viewing all articles
Browse latest Browse all 41

Trending Articles