Вопрос

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!

Это было полезно?

Решение

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

$siteUrl="https://tenant.sharepoint.com/sites/michael"
$ListName="Site Pages"
$UserName="michael"
$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=$list.RootFolder.Files.AddTemplateFile("/sites/michael/SitePages/ModernPage.aspx",[Microsoft.SharePoint.Client.TemplateFileType]::ClientSidePage).ListItemAllFields
$item["ContentTypeId"] = "0x0101009D1CB255DA76424F860D91F20E6C4118";
$item["Title"]="ModernPage"
$item["ClientSideApplicationId"] = "b6917cb1-93a0-4b97-a84d-7cf49975d4ec"
$item["PageLayoutType"] = "Article"
$item["PromotedState"] = "0"
$item["CanvasContent1"] = "<div></div>"
$item["BannerImageUrl"] = "/_layouts/15/images/sitepagethumbnail.png"
$item.Update()
$context.ExecuteQuery()
    
Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top