This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | |
$admin = 'youraccount@tenant.OnMicrosoft.Com' | |
$password = Read-Host 'Enter Password' -AsSecureString | |
$context = New-Object Microsoft.SharePoint.Client.ClientContext("https://tenant.sharepoint.com/sites/testpnp"); | |
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($admin , $password) | |
$context.Credentials = $credentials | |
$pagesLibrary = $context.Web.Lists.GetByTitle('Site Pages'); | |
$context.Load($pagesLibrary); | |
$newPageitem = $pagesLibrary.RootFolder.Files.AddTemplateFile("/sites/testpnp/sitepages/TestPage.aspx", "ClientSidePage").ListItemAllFields; | |
$newPageitem["Title"] = "Project Home"; | |
$newPageitem["ClientSideApplicationId"] = "b6917cb1-93a0-4b97-a84d-7cf49975d4ec"; | |
$newPageitem["PageLayoutType"] = "Article"; | |
$newPageitem["LayoutWebpartsContent"] = '<div><div data-sp-canvascontrol="" data-sp-canvasdataversion="1.4" data-sp-controldata="{"id":"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788","instanceId":"cbe7b0a9-3504-44dd-a3a3-0e5cacd07788","title":"Title Region","description":"Title Region Description","serverProcessedContent":{"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}},"dataVersion":"1.4","properties":{"title":"Project Home","imageSourceType":4,"layoutType":"FullWidthImage","textAlignment":"Left","showTopicHeader":true,"showPublishDate":false,"topicHeader":"Service Line"}}"></div></div>'; | |
$newPageitem["CanvasContent1"] = "<div></div>"; | |
$newPageitem["_TopicHeader"] = "Service Line"; | |
$newPageitem.Update(); | |
$context.Load($newPageitem); | |
$context.ExecuteQuery(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how i can embed code using $newPageitem