I am working on a PowerShell script to provision a site collection with a predefined hierarchy. Since the PowerShell breadth is so limited, most of this is done via functions that are CSOM code.

As part of this, I need to have a unified global navigation. I have been able to enable the publishing feature without problems. My issues arise when I have to step through each site and set the global navigation settings to:

  1. Use structural navigation on the Rootweb, including subsites
  2. In each subsite, inherit from the parent, and include subsites.

I have seen a lot of this floating around for on-prem like Powershell script to update Navigation.GlobalIncludeSubSites not applying change, I need it to work for Office 365. I can't seem to get a right handle on the publishing web and the navigation settings.

Does anyone have a definitive example or a reference to how to modify the current navigation via CSOM in PowerShell for Office 365?

1 Answer 1


In SharePoint 2013 was introduced a new Microsoft.SharePoint.Client.Publishing and Microsoft.SharePoint.Client.Publishing.Navigation namespaces in CSOM API. But unfortunately it is not supported to get/set Show subsites & Show pages navigation settings using WebNavigationSettings class since those properties are not exposed.

Having said that I propose to utilize ClientPortalNavigation.cs which represents a CSOM counterpart for SSOM PortalNavigation Class which in turn allows to get/set navigation settings including Show subsites & Show pages navigation settings.


In order to consume ClientPortalNavigation.cs in PowerShell below is demonstrated how to implement it as a custom PowerShell snap-in.

  • Build an assembly from SharePoint.Client.Navigation.PowerShell project
  • Install the specified assembly using Installer Tool:InstallUtil SharePoint.Client.Navigation.PowerShell.dll
  • Register Windows PowerShell snap-in:Add-PsSnapin SharePoint.Client.Navigation.PowerShell


The example demonstrates how to set SharePoint Online Global navigation Show subsites & Show pages settings via CSOM API in PowerShell:

if ((Get-PSSnapin -Name SharePoint.Client.Navigation.PowerShell -ErrorAction SilentlyContinue) -eq $null)
    Add-PsSnapin SharePoint.Client.Navigation.PowerShell

Function Get-SPOCredentials([string]$UserName,[string]$Password)
   $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
   return New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)

$UserName = "[email protected]"
$Password = Read-Host -Prompt "Enter the password"    
$Url = "https://contoso.sharepoint.com/"
$credentials = Get-SPOCredentials -UserName $UserName -Password $Password
SetGlobalNavigation -Url $Url -Credentials $credentials -IncludePages $true -IncludeSubSites $true 


Access and Manipulate Navigation Settings via SharePoint Client Object Model

  • I can build it, I just can't seem to get PowerShell to recognize it to try it. Commented Aug 5, 2015 at 14:46
  • Probably it could not be recognized by PowerShell since it should be installed using x64 version of InstallUtil.exe (more details) Commented Aug 5, 2015 at 15:10
  • I'll keep trying, would gacutil work too? Commented Aug 5, 2015 at 19:28
  • Eric, for some reason i haven't noticed your last comment, gacutil should work as well. Commented Sep 9, 2015 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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