Geeks With Blogs
Marc Schuricht Killer Cubes

 I was recently asked to develop a script which would allow all sites to inherit the global navigation. Here it is.

 

param

( $rootUrl = "http://litwaredemo" )

"Setting STSADM"

$stsadm

= "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\bin\STSADM.EXE"

"Getting Sites XML"

[

xml] $sites = &$stsadm -o enumsites -url $rootUrl

"Loading Microsoft.SharePoint"

[

[

 

  

System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")

function

{

 

 

[

 

[

 

}

 

 

}

}

 

SetGlobalNav([Microsoft.SharePoint.SPSite] $Site)$site.AllWebs | %{ Microsoft.SharePoint.SPWeb] $web = $SPSite.OpenWeb($_.ServerRelativeUrl)if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) {Microsoft.SharePoint.Publishing.PublishingWeb] $pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)$pweb.InheritGlobalNavigation = $true $web.Dispose()

function

{

 

EnumSiteCollections()"Getting Site Collection"

 

[

 

 

$sites.Sites.Site | %{Microsoft.SharePoint.SPSite] $SPSite = New-Object "Microsoft.SharePoint.SPSite" -argumentList $_.Url"Setting Global Navigation for $($_.Url)" SetGlobalNav $SPSite

 

}

}

$SPSite.Dispose()

EnumSiteCollections

Posted on Monday, July 6, 2009 12:49 PM MOSS 2007 Application Development , Powershell | Back to top


Comments on this post: Inherit Global Navigation

# re: Inherit Global Navigation
Requesting Gravatar...
What is the advantage of doing this as a Powershell script? Why not just create a command line utility? There is no file manipulation going on here.
Left by Marcus Wright on Jul 06, 2009 7:40 AM

Your comment:
 (will show your gravatar)


Copyright © Marc Schuricht | Powered by: GeeksWithBlogs.net