Restore SharePoint Seattle masterpage

With the script that we’re showing, you can reset the masterpage on a SharePoint site and get back to the default masterpage (Seattle). This command can be used by any SharePoint version, a few notes that I want the user to be aware before running this script.

  • It’ll only apply to the site that you’re connected and not all site collection
  • If you’ve custom masterpage with custom zones, you may have an error when accessing to pages because those zones don’t exist on the default masterpage.
  • Make sure you have the $site variable with /
  • On the $ domainUrl make sure you when the line without \.
  • If you’ve other type of security on login check the other options to login on the PnP
$domainUrl  = "https://contoso.sharepoint.com"
$site       = "/sites/contososite"
$username   = "contoso@contoso.onmicrosoft.com"
$password   = "password"

$encpassword = convertto-securestring -String $password -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $encpassword

Connect-PnpOnline -Url $domainUrl$site -Credentials $cred

Set-PnPMasterPage -MasterPageServerRelativeUrl $site/_catalogs/masterpage/seattle.master -CustomMasterPageServerRelativeUrl $site/_catalogs/masterpage/seattle.master 

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *