Get the default page layout for an Enterprise Wiki?

%3CLINGO-SUB%20id%3D%22lingo-sub-34361%22%20slang%3D%22en-US%22%3EGet%20the%20default%20page%20layout%20for%20an%20Enterprise%20Wiki%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34361%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20use%20CSOM%20(Powershell%20or%20C%23)%20to%20get%20the%20default%20page%20layout%20for%20an%20Enterprise%20Wiki%20site%20collection%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34590%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20the%20default%20page%20layout%20for%20an%20Enterprise%20Wiki%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34590%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F29128%22%20target%3D%22_blank%22%3E%40Andrew%20Koltyakov%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20reply%2C%20it%20helped%20me!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20my%20Powershell%20code%20using%20PnP%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EClear-Host%0A%0AConnect-PnPOnline%20-Url%20https%3A%2F%2F%3CTENANT%3E.sharepoint.com%2Fsites%2Fwiki%20-Credentials%20(Get-Credential)%0A%3CBR%20%2F%3E%24context%20%3D%20Get-PnPContext%0A%0A%24allProperties%20%3D%20Get-PnPProperty%20-ClientObject%20%24context.Web%20-Property%20AllProperties%3CBR%20%2F%3E%3CBR%20%2F%3E%24defaultLayoutPage%20%3D%20%24allProperties%5B'__DefaultPageLayout'%5D%0A%0A%24defaultLayoutPage%0A%0ADisconnect-PnPOnline%3C%2FTENANT%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34579%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20the%20default%20page%20layout%20for%20an%20Enterprise%20Wiki%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34579%22%20slang%3D%22en-US%22%3E%3CP%3ESharePoint%20Folder%20object%20has%20%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fmicrosoft.sharepoint.client.folder.welcomepage.aspx%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EWelcomePage%20property%3C%2FA%3E.%3C%2FP%3E%3CP%3EE.g.%2C%20for%20a%20web%3A%20%60oWeb.RootFolder.WelcomePage%60.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.learningsharepoint.com%2F2013%2F04%2F29%2Fhow-to-change-a-default-layout-for-add-a-page-in-sharepoint-2013%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EPage%20layout%3C%2FA%3E%20is%20not%20the%20same.%20For%20publishing%20web%20a%20default%20layout%20can%20be%3A%3C%2FP%3E%3CP%3E-%20Gotten%20by%20retrieving%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Foffice%2Fmicrosoft.sharepoint.publishing.publishingweb.defaultpagelayout.aspx%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EDefaultPageLayout%3C%2FA%3E%26nbsp%3Bproperty%3C%2FP%3E%3CP%3E-%20Redefined%20by%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fmicrosoft.sharepoint.publishing.publishingweb.setdefaultpagelayout.aspx%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ESetDefaultPageLayout%3C%2FA%3E%26nbsp%3Bmethod%3C%2FP%3E%3CP%3EAlso%2C%20you%20can%20get%20a%20list%20of%20available%20page%20layouts%3A%3C%2FP%3E%3CP%3E-%20%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fmicrosoft.sharepoint.publishing.publishingweb.getavailablepagelayouts.aspx%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EGetAvailablePageLayouts%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EPublishingWeb%20pubWeb%20%3D%20PublishingWeb.GetPublishingWeb(oWeb)%3B%0APageLayout%20pageLayout%20%3D%20pubWeb.DefaultPageLayout%3B%0AConsole.WriteLine(%22Title%3A%20%22%20%2B%20pageLayout.Name%20%2B%20%22%2C%20Url%3A%20%22%20%2B%20pageLayout.ServerRelativeUrl)%3B%3C%2FPRE%3E%3CP%3E%3CSPAN%3EHope%20this%20was%20helpful.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34576%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20Get%20the%20default%20page%20layout%20for%20an%20Enterprise%20Wiki%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34576%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%40Deleted%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20not%20the%20homepage%2C%20but%20the%20default%20layout%20page%20that%20would%20be%20used%20when%20creating%20new%20Enterprise%20Wiki%20pages.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-34570%22%20slang%3D%22en-US%22%3ERE%3A%20Get%20the%20default%20page%20layout%20for%20an%20Enterprise%20Wiki%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-34570%22%20slang%3D%22en-US%22%3EYou%20could%20get%20the%20homepage%20of%20any%20sitecollection%20using%20PNP%20%3CA%20href%3D%22https%3A%2F%2Fdev.office.com%2Fpatterns-and-practices%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.office.com%2Fpatterns-and-practices%3C%2FA%3E%3C%2FLINGO-BODY%3E
Contributor

Hi

 

Is there a way to use CSOM (Powershell or C#) to get the default page layout for an Enterprise Wiki site collection?

 

Thanks.

4 Replies
You could get the homepage of any sitecollection using PNP https://dev.office.com/patterns-and-practices

Hi @Deleted

 

It's not the homepage, but the default layout page that would be used when creating new Enterprise Wiki pages.

 

Thanks.

SharePoint Folder object has WelcomePage property.

E.g., for a web: `oWeb.RootFolder.WelcomePage`.

 

Page layout is not the same. For publishing web a default layout can be:

- Gotten by retrieving DefaultPageLayout property

- Redefined by SetDefaultPageLayout method

Also, you can get a list of available page layouts:

- GetAvailablePageLayouts

 

PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(oWeb);
PageLayout pageLayout = pubWeb.DefaultPageLayout;
Console.WriteLine("Title: " + pageLayout.Name + ", Url: " + pageLayout.ServerRelativeUrl);

Hope this was helpful.

Hi @Andrew Koltyakov

 

Thanks for your reply, it helped me!

 

Here is my Powershell code using PnP:

 

Clear-Host

Connect-PnPOnline -Url https://<tenant>.sharepoint.com/sites/wiki -Credentials (Get-Credential)

$context = Get-PnPContext $allProperties = Get-PnPProperty -ClientObject $context.Web -Property AllProperties

$defaultLayoutPage = $allProperties['__DefaultPageLayout'] $defaultLayoutPage Disconnect-PnPOnline