문제

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