Skip to main content

Creating a new blank page with a text webpartweb part in sharepoint onlineSharePoint Online using powershellPowerShell

i'mI'm quite new to using powershellPowerShell and sharepointSharePoint, and i'veI've been running into issues creating a new page on a subsite. I've been trying to follow code iI found here: https://sharepointstew.wordpress.com/2015/03/09/csom-powershell-to-create-a-sharepoint-publishing-page-with-custom-or-oob-page-layout/ and here: https://www.sharepointdiary.com/2018/04/sharepoint-online-create-publishing-page-using-powershell.html

I think the issue is that it's trying to find blankwebpartblank web part.aspx in the master page gallery in my subsite, however, checking there iI have no blankwebpart.aspx files there or in the root web masterwebmaster page gallery. I've also tried running it on my rootwebroot web with DefaultLayout.aspx but still the same issues. I'm kind of at a loss for how to proceed, here'shere are some of the errors i'mI'm running into:

I'm using the sharepoint onlineSharePoint Online management shell and have the sharepointSharePoint dll's installed and all. I'm sure i'mI'm missing something plainly obvious here, cheers

Creating a new blank page with a text webpart in sharepoint online using powershell

i'm quite new to using powershell and sharepoint, and i've been running into issues creating a new page on a subsite. I've been trying to follow code i found here: https://sharepointstew.wordpress.com/2015/03/09/csom-powershell-to-create-a-sharepoint-publishing-page-with-custom-or-oob-page-layout/ and here: https://www.sharepointdiary.com/2018/04/sharepoint-online-create-publishing-page-using-powershell.html

I think the issue is that it's trying to find blankwebpart.aspx in the master page gallery in my subsite, however checking there i have no blankwebpart.aspx files there or in the root web master page gallery. I've also tried running it on my rootweb with DefaultLayout.aspx but still same issues. I'm kind of at a loss for how to proceed, here's some of the errors i'm running into:

I'm using the sharepoint online management shell and have the sharepoint dll's installed and all. I'm sure i'm missing something plainly obvious here, cheers

Creating a new blank page with a text web part in SharePoint Online using PowerShell

I'm quite new to using PowerShell and SharePoint, and I've been running into issues creating a new page on a subsite. I've been trying to follow code I found here: https://sharepointstew.wordpress.com/2015/03/09/csom-powershell-to-create-a-sharepoint-publishing-page-with-custom-or-oob-page-layout/ and here: https://www.sharepointdiary.com/2018/04/sharepoint-online-create-publishing-page-using-powershell.html

I think the issue is that it's trying to find blank web part.aspx in the master page gallery in my subsite, however, checking there I have no blankwebpart.aspx files there or in the root webmaster page gallery. I've also tried running it on my root web with DefaultLayout.aspx but still the same issues. I'm kind of at a loss for how to proceed, here are some of the errors I'm running into:

I'm using the SharePoint Online management shell and have the SharePoint dll's installed and all. I'm sure I'm missing something plainly obvious here, cheers

Source Link

Creating a new blank page with a text webpart in sharepoint online using powershell

i'm quite new to using powershell and sharepoint, and i've been running into issues creating a new page on a subsite. I've been trying to follow code i found here: https://sharepointstew.wordpress.com/2015/03/09/csom-powershell-to-create-a-sharepoint-publishing-page-with-custom-or-oob-page-layout/ and here: https://www.sharepointdiary.com/2018/04/sharepoint-online-create-publishing-page-using-powershell.html

I think the issue is that it's trying to find blankwebpart.aspx in the master page gallery in my subsite, however checking there i have no blankwebpart.aspx files there or in the root web master page gallery. I've also tried running it on my rootweb with DefaultLayout.aspx but still same issues. I'm kind of at a loss for how to proceed, here's some of the errors i'm running into:

function returnThings($Context) {
    $List = $Context.Web.Lists
    $Context.load($List)
    $Context.executeQuery()

    $mpList = $List.GetByTitle("Master Page Gallery")

    $PageLayoutName = "DefaultLayout.aspx"
    $camlQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
    $camlQuery.ViewXml = '<View><Query><Where><Eq><FieldRef Name="FileLeafRef" /><Value Type="Text">' + $PageLayoutName + '</Value></Eq></Where></Query></View>'
    $items = $mpList.GetItems($camlQuery)
    $Context.Load($items)
    $Context.ExecuteQuery()
    $pageLayoutItem = $items[0]
    $Context.Load($pageLayoutItem)

    foreach ($PageL in $items) {
        write-host "See below: " -ForegroundColor Blue
        $PageL | ConvertTo-Csv
    }

    # Get publishing web object
    #
    $web = $Context.Web
    $pubWeb = [Microsoft.SharePoint.Client.Publishing.PublishingWeb]::GetPublishingWeb($Context, $web)
    $Context.Load($pubWeb)
 
    #Get pages library.
    
    $pagesList = $Context.Web.Lists.GetByTitle("Pages")

    $PageName = "Project Deviations"

    $pubPageInfo = New-Object Microsoft.SharePoint.Client.Publishing.PublishingPageInformation
    $pubPageInfo.Name = $PageName.Replace(" ", "-") + ".aspx"
    $pubPageInfo.PageLayoutListItem = $pageLayoutItem 
    $pubPage = $pubWeb.AddPublishingpage($pubPageInfo)
   
    $pubPage.ListItem.File.CheckIn("", [Microsoft.SharePoint.Client.CheckinType]::MajorCheckIn)
    $pubPage.ListItem.File.Publish("")
    $pubPage.ListItem.File.Approve("")
   
    $Context.Load($pubPage) 
    $Context.ExecuteQuery()
}
Exception calling "ExecuteQuery" with "0" argument(s): "List 'Pages' does not exist at site with URL
'https://companydemo2.sharepoint.com/sites/TEAM'."
At C:\Users\conormo\Documents\Sharepoint Repos\KcentralMigration\Scripts\testProjDeviations.ps1:70 char:5
+     $Context.ExecuteQuery()
+     ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ServerException

I'm using the sharepoint online management shell and have the sharepoint dll's installed and all. I'm sure i'm missing something plainly obvious here, cheers