0

I want to show or hide subsite link from Parent site top navigation. e.g. from UI i can do it by

  • Show or hide individual sub sites and pages
    • On the Site Actions menu, click Site Settings.
    • On the Site Actions menu, point to Site Settings, and then click Modify All Site Settings.
    • In the Look and Feel column, click Navigation.
    • In the Navigation Editing and Sorting section, select the sub site or page you want and do one of the following:
    • If you want to show a page or subsite that is hidden, select the item, and then click Show.
    • If you want to hide a page or subsite that is currently visible, select the item, and then click Hide.

Now i want to hide/show specific subsite using PowerShell. I little know PowerShell. Is there any example of it?

1

You can hide a subsite with the following script:

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

$web = Get-SPWeb http://SubSiteUrl...
$publishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$publishingWeb.IncludeInGlobalNavigation = $false
$publishingWeb.Update();
$web.Dispose()

To delete a heading or a link use this script:

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

$rootWeb = Get-SPWeb http://rootWebUrl...
$rootWeb.AllowUnsafeUpdates = $true
$topNavLink = $web.Navigation.TopNavigationBar[index] #index of the link you want to delete
$topNavLink.Delete()
$rootWeb.AllowUnsafeUpdates = $false

$web.Dispose()
  • Glad to hear that – Naim Murati Aug 27 '14 at 10:14
1

Found the solution to this one myself:

$web = Get-SPWeb http://server/sites/site/web
 $pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb ($web)
 Global Showsubsites and pages:
 $pubWeb.Navigation.GlobalIncludeSubSites = $true
 $pubWeb.Navigation.GlobalIncludePages = $true

Current Showsubsites and pages:
$pubWeb.Navigation.CurrentIncludeSubSites = $true
$pubWeb.Navigation.CurrentIncludePages = $true

Don't forget update:

$pubWeb.Update()
$web.Dispose()

Done!

More info here: http://get-spscripts.com/2011/04/managing-quick-launch-current.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.