The SharePoint Coffee House
I'd like some SharePoint with my coffee please...

PowerShell Script to Change Navigation Inheritance

Friday, 1 April 2011 18:13 by Michael Mukalian

The question was asked of how to change the inheritance of subsites under a site collection via PowerShell, as there could be a ton of sites under the root.  Turns out, it's not too hard.  Check out the script below.  This sets all the subsites to inherit...

# get the site collection
$spSite = Get-SPSite -Identity "http://sitecollection"
# loop through all the webs in the site collection
foreach ($spWeb in $spSite.AllWebs)
{
	# check if root web as this one doesn't obviously inherit
	if (!$spWeb.IsRootWeb)
{
		# grab a Navigation object
		$spWebNavigation = $spWeb.Navigation
		# change to true
		$spWebNavigation.UseShared = $true
}
	# cleanup
	$spWeb.Dispose()
}
# cleanup
$spSite.Dispose()

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   2010 | PowerShell
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed