Manage SharePoint communication site megamenu with CSOM and PowerShell

You may have already noticed that site navigation style have changed on newly created SharePoint Online communication sites. Experience is currently different on sites created earlier.

navi.PNG
Megamenu navigation enabled
navi2
Old style navigation

Here is a quick-n-dirty PowerShell script to change experience back to old style navigation on newly created communication sites.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null

$webUrl = "<site url>"
$username = "<username>@<tenant>.onmicrosoft.com"
$pw = read-host -Prompt "Enter password" -AsSecureString

$ctx= New-Object Microsoft.SharePoint.Client.ClientContext($webURL)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username,$pw)
$ctx.Load($ctx.Web)
$ctx.ExecuteQuery()
$ctx.Web.MegaMenuEnabled = $false //Disables megamenu experience
$ctx.Web.Update()
$ctx.ExecuteQuery()


Edited 22.8.2018 17.33:

Of course you can do it with PnP PowerShell.

Connect-PnPOnline -Url <yoursite>
$web = Get-PnPWeb
$web.MegaMenuEnabled = $false //$false to disable, $true to enable
$web.Update()
Invoke-PnPQuery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: