Forum Discussion

Russell Gove's avatar
Russell Gove
Iron Contributor
Oct 10, 2016

Programattically set global Navigation Settinigs in O365 sharepoint

Hi,

Is there any way to  programattically set the Global navigation settings in Sharepoint Online

Can the PnP-Powershell commands set this?

    • Russell Gove's avatar
      Russell Gove
      Iron Contributor

      Thanks Juan, that helped. It can be done using the PNP-Powershell commands:

      Connect-SPOnline -Url https://tenant.sharepoint.com/teams/IT/Applications -Credentials o365
      $context=get-spocontext 
      $web=$context.Web 
      
      $context.Load($web)
      $siteLogoUrl=$web.SiteLogoUrl
      
      $props=$web.AllProperties
      $context.Load($props)
      
      $nav=$web.Navigation
      $context.Load($nav)
      
      $context.ExecuteQuery();
      
      $nav.UseShared=$true #Display the same navigation items as the parent site 
      $props["__GlobalNavigationIncludeTypes"]=1 #show Subsites
      $web.Update()
      
      $context.ExecuteQuery();

Resources