1 min read
PowerShellSharePoint 2013

SharePoint 2013: Creating a Publishing Page and assigning a page layout using PowerShell

The following PowerShell can be used to create a publishing page and assign a page layout.

#Get SPWeb
$spWeb = Get-SPWeb(“Site URL”);
#Get Publishing Web
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spWeb)
#Finds the appropriate page layout
$pl = $pubWeb.GetAvailablePageLayouts() | Where { $_.Name -eq “Page Layout Name”}
$pages = $pubWeb.GetPublishingPages();
#Create the page;
$page = $pages.Add(“Page Name”, $pl)
#Check in Page
$page.CheckIn(“Created by PowerShell”);
#Dispose of SPWeb
$spWeb.Dispose();

Want more cloud insights? Listen to Cloudy with a Chance of Insights podcast:

Spotify | YouTube | Apple Podcasts

Like this article?

Comments

Richard Hogan

Richard Hogan

Author & Host

Richard is a Microsoft-focused architect and consultant with deep expertise in Azure, Microsoft 365, cybersecurity, and enterprise cloud migration. He is the founder of The Microsoft Cloud Blog and co-host of the Cloudy with a Chance of Insights podcast. All views expressed are his own.

You might also like

In-depth cloud tech discussions from Microsoft experts.

Expert insights on Microsoft Azure, cloud architecture, and enterprise technology.