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.
4 Replies
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 TraffordBrass 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
- AnonymousYou could get the homepage of any sitecollection using PNP https://dev.office.com/patterns-and-practices
- Alan TraffordBrass Contributor
Hi Deleted
It's not the homepage, but the default layout page that would be used when creating new Enterprise Wiki pages.
Thanks.