PowerShell Get Sub Webs of a Web

If you are looking for a way to get all of the subsites for a given site, PowerShell can help.

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

$spWeb = Get-SPweb "http://sharepointed.com/sites/taco"

	foreach($subSite in $spWeb.Webs)
		{
			$subSite.Title
			$subSite.Dispose()
		}

$spWeb.Dispose()

1. add the SharePoint Snapin
2. get the site that we want to dig into.
3. loop on each subsite
3.1. display the site title
3.2. close the connection to the subsite.
4. close the connection to the site we dug into.

Leave a Reply

Your email address will not be published. Required fields are marked *