I want to create modern page in a modern site using CSOM PowerShell instead of PNP. After creating that I need to configure list and Events we part in that.

Please guide me on this.

Thanks in advance!

1 Answer 1


You can use the below csom script to create modern page:

$ListName="Site Pages"
$Password ="password"
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $credentials
$List = $Context.web.Lists.GetByTitle($ListName)
$item["ContentTypeId"] = "0x0101009D1CB255DA76424F860D91F20E6C4118";
$item["ClientSideApplicationId"] = "b6917cb1-93a0-4b97-a84d-7cf49975d4ec"
$item["PageLayoutType"] = "Article"
$item["PromotedState"] = "0"
$item["CanvasContent1"] = "<div></div>"
$item["BannerImageUrl"] = "/_layouts/15/images/sitepagethumbnail.png"
  • Thanks a lot for putting your time, Michael. Can I insert/configure the default webparts like "Events","Announcement" while creating the modern page? Nov 16, 2020 at 6:24
  • As far as I know, there is no CSOM API's to add webparts to modern page. You'd better use PNP powershell to add web parts to modern page. Nov 16, 2020 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.