Is there a way to tick the "Set default selection" property of a page template, so that it will be use as the default page template?

enter image description here

I'm trying to find a way of doing this programmatically, preferably with PowerShell / PnP but so far I have found no clues on how this can be done.

  • Where is this "Set default selection" option in SharePoint UI? Can you add any screenshot to your question if possible? Apr 11 at 10:59
  • @GaneshSanap updated post with screenshot of the UI. It is in the Create Page / News dialog Apr 11 at 11:36

1 Answer 1


SharePoint is managing default page template using Web Property Bag with name DefaultNewPageTemplateId where it's storing Unique Id of File object of Site Page List Item.

enter image description here

You can set this property bag using any object model e.g. REST API, CSOM, PnP.PowerShell.

Below is the same for doing same using PnP.PowerShell

Connect-PnPOnline "https://contoso.sharepoint.com/sites/testcommunity" -Interactive
$page = Get-PnPPage -Identity "Templates/Page-Template-2.aspx" #Relative Page Template Url
$pageFile = $page.GetPageFile()
$web = Get-PnPWeb
Add-PnPPropertyBagValue -Key "DefaultNewPageTemplateId" -Value $pageFile.UniqueId -Web $web

If you receive error like (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Site might have NoScript enabled, this prevents setting some property bag values. In this case you need enable scripting which you can set using SharePoint Online Management Shell. Below are the commands for the same:

Connect-SPOService -Url https://contoso-admin.sharepoint.com
Set-SPSite -Identity "https://contoso.sharepoint.com/sites/testcommunity" -DenyAddAndCustomizePages 0

Note: I couldn't find any official documentation for that but I am big fan of SharePoint Client Browser which helps me most of the time for this kind of scenario when I don't get anything from official Microsoft documentation :)

  • Thanks, this seems to work well. Too bad we need to Enable scripting to make it work. Apr 11 at 13:44

Your Answer

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

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