I created custom html page layout with embedded web part in it. When I am trying to add page to pages library by powershell getting below error
Fail: Exception calling "AddPublishingPage" with "2" argument(s): "No parameterless constructor defined for this object."
at $Page = $PubWeb.AddPublishingPage($PageName, $PageLayout)
Strange part is. When I create page manually with same page layout its getting created and once I create it manually. My Script is working fine. I can create pages withouts error once I create page manually.
Not sure what is happning here
Script below :
$PageTitle = $newPage.NewPageTitle
$Layouts = $PubSite.GetPageLayouts($False)
foreach($layout in $Layouts){
if($layout.Name -eq $PageLayoutRelUrl){
$PageLayout = $layout
}
}
$Page = $PubWeb.AddPublishingPage($PageName, $PageLayout)
$Page.Title = $PageTitle
$Page.Update();
$Page.CheckIn("Deployment CheckIn")
$Page.ListItem.File.Publish("Deplyment Pulish")