Forum Discussion
Alan Trafford
Dec 07, 2016Brass Contributor
Get the default page layout for an Enterprise Wiki?
Hi Is there a way to use CSOM (Powershell or C#) to get the default page layout for an Enterprise Wiki site collection? Thanks.
Dec 08, 2016
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:
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(oWeb);
PageLayout pageLayout = pubWeb.DefaultPageLayout;
Console.WriteLine("Title: " + pageLayout.Name + ", Url: " + pageLayout.ServerRelativeUrl);Hope this was helpful.
Alan Trafford
Dec 08, 2016Brass Contributor
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