none
Powershell Script to Set Current Navigation in Navigation Settings RRS feed

  • Question

  • Dear All,

    I need to set an Current navigation to Managed Navigation in Navigation settings through the Powershell scripts.

    Thanks in advance.


    Pravin Dhulap

    Tuesday, September 23, 2014 2:17 PM

Answers

  • Hope below should help you

    http://jespermchristensen.wordpress.com/2013/01/16/set-sharepoint-2013-navigation-settings-from-powershell/

    Write-Host -ForegroundColor White "Set the SharePoint 2010 and 2013 Navigation Settings on Sites"
    
    #Set the Site Collection
    $SPSite = Get-SPSite -Identity "http://extrico-demo2.dev.extrico.local/sites/demo1"
    
    #Go through each site in the Site Collection
    foreach ($SPWeb in $SPSite.AllWebs)
    {
    if ($SPWeb.IsRootWeb)
    {#Process the root web
    Write-Host -ForegroundColor Gray $SPWeb.Url":" -NoNewLine
    #Save the AllowUnsafeUpdatesStatus property value
    $AllowUnsafeUpdatesStatus = $SPWeb.AllowUnsafeUpdates
    $SPWeb.AllowUnsafeUpdates = $true
    
    #Set the Publishing Web
    $SPPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($SPWeb)
    
    #Global Navigation Settings
    $SPPubWeb.Navigation.InheritGlobal = $false
    $SPPubWeb.Navigation.GlobalIncludeSubSites = $true
    $SPPubWeb.Navigation.GlobalIncludePages = $false
    $SPPubWeb.Navigation.GlobalDynamicChildLimit = 21
    
    #Current Navigation Settings
    #
    # -Display the same navigation items as the parent site: InheritCurrent = $true and ShowSiblings = $false
    # -Structural Navigation: Display the current site, the navigation items below the current site, and the current site's siblings: InheritCurrent = $false and ShowSiblings = $true
    # -Structural Navigation: Display only the navigation items below the current site: InheritCurrent = $false and ShowSiblings = $false
    #
    $SPPubWeb.Navigation.InheritCurrent = $false
    $SPPubWeb.Navigation.ShowSiblings = $true
    $SPPubWeb.Navigation.CurrentIncludeSubSites = $false
    $SPPubWeb.Navigation.CurrentIncludePages = $false
    $SPPubWeb.Navigation.CurrentDynamicChildLimit = 21
    
    # Sorting
    $SPPubWeb.Navigation.OrderingMethod = "Manual" # "Automatic" "ManualWithAutomaticPageSorting"
    $SPPubWeb.Navigation.AutomaticSortingMethod = "Title" # "CreatedDate" "CreatedDate" "LastModifiedDate"
    $SPPubWeb.Navigation.SortAscending = $true
    
    #Update the Publishing Web Navigation Settings
    $SPPubWeb.Update()
    Write-Host -ForegroundColor Green " Done"
    }
    else
    {#Process all sub-webs to the root web
    
    Write-Host -ForegroundColor Gray $SPWeb.Url":" -NoNewLine
    
    #Save the AllowUnsafeUpdatesStatus property value
    $AllowUnsafeUpdatesStatus = $SPWeb.AllowUnsafeUpdates
    $SPWeb.AllowUnsafeUpdates = $true
    
    #Set the Publishing Web
    $SPPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($SPWeb)
    
    #Global Navigation Settings
    $SPPubWeb.Navigation.InheritGlobal = $true
    $SPPubWeb.Navigation.GlobalIncludeSubSites = $true
    $SPPubWeb.Navigation.GlobalIncludePages = $false
    $SPPubWeb.Navigation.GlobalDynamicChildLimit = 21
    
    #Current Navigation Settings
    $SPPubWeb.Navigation.InheritCurrent = $false
    $SPPubWeb.Navigation.ShowSiblings = $true
    $SPPubWeb.Navigation.CurrentIncludeSubSites = $false
    $SPPubWeb.Navigation.CurrentIncludePages = $false
    $SPPubWeb.Navigation.CurrentDynamicChildLimit = 21
    
    # Sorting
    $SPPubWeb.Navigation.OrderingMethod = "Manual" # "Automatic" "ManualWithAutomaticPageSorting"
    $SPPubWeb.Navigation.AutomaticSortingMethod = "Title" # "CreatedDate" "CreatedDate" "LastModifiedDate"
    $SPPubWeb.Navigation.SortAscending = $true
    
    #Update the Publishing Web Navigation Settings
    $SPPubWeb.Update()
    Write-Host -ForegroundColor Green " Done"
    }
    
    #Revert the AllowUnsafeUpdatesStatus property value
    $SPWeb.AllowUnsafeUpdates = $AllowUnsafeUpdatesStatus
    
    #Dispose the SPWeb object
    $SPWeb.Dispose()
    }
    
    #Dispose the SPSite object
    $SPSite.Dispose()

    http://radutut.wordpress.com/2013/03/11/managed-metadata-navigation-settings-in-sharepoint-2013-using-powershell/

    http://www.sharepointstuffs.com/powershell-to-create-and-reuse-managed-navigation-for-multiple-sites-in-sharepoint-2013/


    If this helped you resolve your issue, please mark it Answered

    • Marked as answer by JasonGuo Monday, October 6, 2014 11:01 AM
    Tuesday, September 23, 2014 2:35 PM
    Moderator
  • Here's the PowerShell script that sets the heading and link for your current (left) navigation.

    http://sundarnarasiman.net/?p=94


    Please mark the replies as answers if they help or unmark if not.

    • Marked as answer by JasonGuo Monday, October 6, 2014 11:01 AM
    Thursday, September 25, 2014 9:58 AM

All replies

  • Hope below should help you

    http://jespermchristensen.wordpress.com/2013/01/16/set-sharepoint-2013-navigation-settings-from-powershell/

    Write-Host -ForegroundColor White "Set the SharePoint 2010 and 2013 Navigation Settings on Sites"
    
    #Set the Site Collection
    $SPSite = Get-SPSite -Identity "http://extrico-demo2.dev.extrico.local/sites/demo1"
    
    #Go through each site in the Site Collection
    foreach ($SPWeb in $SPSite.AllWebs)
    {
    if ($SPWeb.IsRootWeb)
    {#Process the root web
    Write-Host -ForegroundColor Gray $SPWeb.Url":" -NoNewLine
    #Save the AllowUnsafeUpdatesStatus property value
    $AllowUnsafeUpdatesStatus = $SPWeb.AllowUnsafeUpdates
    $SPWeb.AllowUnsafeUpdates = $true
    
    #Set the Publishing Web
    $SPPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($SPWeb)
    
    #Global Navigation Settings
    $SPPubWeb.Navigation.InheritGlobal = $false
    $SPPubWeb.Navigation.GlobalIncludeSubSites = $true
    $SPPubWeb.Navigation.GlobalIncludePages = $false
    $SPPubWeb.Navigation.GlobalDynamicChildLimit = 21
    
    #Current Navigation Settings
    #
    # -Display the same navigation items as the parent site: InheritCurrent = $true and ShowSiblings = $false
    # -Structural Navigation: Display the current site, the navigation items below the current site, and the current site's siblings: InheritCurrent = $false and ShowSiblings = $true
    # -Structural Navigation: Display only the navigation items below the current site: InheritCurrent = $false and ShowSiblings = $false
    #
    $SPPubWeb.Navigation.InheritCurrent = $false
    $SPPubWeb.Navigation.ShowSiblings = $true
    $SPPubWeb.Navigation.CurrentIncludeSubSites = $false
    $SPPubWeb.Navigation.CurrentIncludePages = $false
    $SPPubWeb.Navigation.CurrentDynamicChildLimit = 21
    
    # Sorting
    $SPPubWeb.Navigation.OrderingMethod = "Manual" # "Automatic" "ManualWithAutomaticPageSorting"
    $SPPubWeb.Navigation.AutomaticSortingMethod = "Title" # "CreatedDate" "CreatedDate" "LastModifiedDate"
    $SPPubWeb.Navigation.SortAscending = $true
    
    #Update the Publishing Web Navigation Settings
    $SPPubWeb.Update()
    Write-Host -ForegroundColor Green " Done"
    }
    else
    {#Process all sub-webs to the root web
    
    Write-Host -ForegroundColor Gray $SPWeb.Url":" -NoNewLine
    
    #Save the AllowUnsafeUpdatesStatus property value
    $AllowUnsafeUpdatesStatus = $SPWeb.AllowUnsafeUpdates
    $SPWeb.AllowUnsafeUpdates = $true
    
    #Set the Publishing Web
    $SPPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($SPWeb)
    
    #Global Navigation Settings
    $SPPubWeb.Navigation.InheritGlobal = $true
    $SPPubWeb.Navigation.GlobalIncludeSubSites = $true
    $SPPubWeb.Navigation.GlobalIncludePages = $false
    $SPPubWeb.Navigation.GlobalDynamicChildLimit = 21
    
    #Current Navigation Settings
    $SPPubWeb.Navigation.InheritCurrent = $false
    $SPPubWeb.Navigation.ShowSiblings = $true
    $SPPubWeb.Navigation.CurrentIncludeSubSites = $false
    $SPPubWeb.Navigation.CurrentIncludePages = $false
    $SPPubWeb.Navigation.CurrentDynamicChildLimit = 21
    
    # Sorting
    $SPPubWeb.Navigation.OrderingMethod = "Manual" # "Automatic" "ManualWithAutomaticPageSorting"
    $SPPubWeb.Navigation.AutomaticSortingMethod = "Title" # "CreatedDate" "CreatedDate" "LastModifiedDate"
    $SPPubWeb.Navigation.SortAscending = $true
    
    #Update the Publishing Web Navigation Settings
    $SPPubWeb.Update()
    Write-Host -ForegroundColor Green " Done"
    }
    
    #Revert the AllowUnsafeUpdatesStatus property value
    $SPWeb.AllowUnsafeUpdates = $AllowUnsafeUpdatesStatus
    
    #Dispose the SPWeb object
    $SPWeb.Dispose()
    }
    
    #Dispose the SPSite object
    $SPSite.Dispose()

    http://radutut.wordpress.com/2013/03/11/managed-metadata-navigation-settings-in-sharepoint-2013-using-powershell/

    http://www.sharepointstuffs.com/powershell-to-create-and-reuse-managed-navigation-for-multiple-sites-in-sharepoint-2013/


    If this helped you resolve your issue, please mark it Answered

    • Marked as answer by JasonGuo Monday, October 6, 2014 11:01 AM
    Tuesday, September 23, 2014 2:35 PM
    Moderator
  • Here's the PowerShell script that sets the heading and link for your current (left) navigation.

    http://sundarnarasiman.net/?p=94


    Please mark the replies as answers if they help or unmark if not.

    • Marked as answer by JasonGuo Monday, October 6, 2014 11:01 AM
    Thursday, September 25, 2014 9:58 AM