SharePoint Online: Change Navigation Settings using PowerShell
Requirement: SharePoint Online Set navigation using PowerShell
How to Change Navigation in SharePoint Online?
To change navigation in SharePoint Online, Go to:
SharePoint Online: Set Navigation using PowerShell
Here is the PowerShell to set SharePoint Online navigation.
How to Change Navigation in SharePoint Online?
To change navigation in SharePoint Online, Go to:
- Site Settings >> "Navigation" under "Look and Feel" group
- Set the navigation settings for global navigation and current navigation accordingly.
SharePoint Online: Set Navigation using PowerShell
Here is the PowerShell to set SharePoint Online navigation.
#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Taxonomy.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Publishing.dll" #Config Parameters $SiteURL= "https://crescent.sharepoint.com/sites/marketing/2018" #Get Credentials to connect $Cred = Get-Credential Try { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL) $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password) #Get the Web $Web = $Ctx.Web $ctx.Load($Web) $Ctx.ExecuteQuery() $TaxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($Ctx) $NavigationSettings = New-Object Microsoft.SharePoint.Client.Publishing.Navigation.WebNavigationSettings($Ctx, $Web) #Set Both current and global navigation settings to structural - Other values: PortalProvider,InheritFromParentWeb ,TaxonomyProvider $NavigationSettings.GlobalNavigation.Source = "PortalProvider" $NavigationSettings.CurrentNavigation.Source = "PortalProvider" #Show subsites in Global navigation $Web.AllProperties["__IncludeSubSitesInNavigation"] = $True #Show pages in global navigation $Web.AllProperties["__IncludePagesInNavigation"] = $False #Maximum number of dynamic items to in global navigation $web.AllProperties["__GlobalDynamicChildLimit"] = 15 #Update Settings $Web.Update() $NavigationSettings.Update($TaxonomySession) $Ctx.ExecuteQuery() Write-host -f Green "Navigation Settings Updated!" } Catch { write-host -f Red "Error Updating Navigation Settings!" $_.Exception.Message }
No comments:
Please Login and comment to get your questions answered!