Publishing
4 TopicsWhich property indicates the published status of a modern page?
I've been under the impression that modern pages use the ows__ModerationStatus indicate whether or not the page is published - just like with classic publishing pages. Last week, I tried to map this crawled property to a RefinableString*** to make it available for the Search index. One week later this managed property still contains no values. With PowerShell I can verify that those modern pages' internal field contains a value indicating the published state and that they also change based on when I publish a modern page in the browser. a) I can't figure out why the managed property doesn't get populated with values from modern pages. It does from classic publishing pages, though b) is there another property at play here indicating the published state for a modern page, e.g. from a communication site? Thanks for your help.1.6KViews0likes0CommentsSharePoint: How to export all the Publishing pages from a complete site collection to CSV Stats
When the Intranet site built in SharePoint Online is based on the Publishing site (not modern) with a complex structure: Each department placed as subsite Difference between the countries and region (organized in Treeview) Difference between business and function ... We have at the end a large number of subsites with the news published in each. The only way to present the result to the user into aggregated view is to pass threw the search engine and the associated queries. The question of statistic will become hard to give the answers for the following question: What is the department with the biggest news number? What is the number of news published per month? Who is the most active content manager? ... The only way to give that feedback is to export all the news (with couple of metadata) into a CSV and apply the Excel transformation (or PowerBI) to create simple presentation mode. The following script will give you that kind of export, you only have to adapt the search query and fields to get from the Search to have your result. [string]$SitePagesURL = "https://yourtenant.sharepoint.com" [DateTime]$PortalPublishingDate = Get-Date [string]$CSVFileName = "ExportAllNewsItems.csv" [string]$queryText = "ContentTypeId:0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00DAB155038B062847A409F1E450E9E5E3* Path:https://yourtenant.sharepoint.com/intranet " [string]$outputline = "" [int]$TempUserID = 0 # --------------------------------------------------------------------------------------------------------------- function Load-DLLandAssemblies { [string]$defaultDLLPath = "" # Load assemblies to PowerShell session $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) $defaultDLLPath = "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client.Search\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Search.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) } function Get-SearchResults([int] $startIndex, $myclientContext) { try { $keywordQuery = New-Object Microsoft.SharePoint.Client.Search.Query.KeywordQuery($MyctxTemp) $keywordQuery.StartRow = $startIndex #gets or sets the first row of information from the search results $keywordQuery.QueryText = $queryText $keywordQuery.RowLimit = 500 $keywordQuery.RowsPerPage = 500 $keywordQuery.TrimDuplicates=$false $keywordQuery.Timeout = 10000; $keywordQuery.SelectProperties.Add("LastModifiedTime") $keywordQuery.SelectProperties.Add("RefinableDate00") # Date Article $keywordQuery.SelectProperties.Add("RefinableString00") # Business & Function $keywordQuery.SelectProperties.Add("RefinableString01") # News Type $keywordQuery.SelectProperties.Add("RefinableString03") # Publishing Area / Country $keywordQuery.SelectProperties.Add("CreatedBy") $keywordQuery.SortList.Add("RefinableDate00","Desc") $searchExecutor = New-Object Microsoft.SharePoint.Client.Search.Query.SearchExecutor($MyctxTemp) $ClientResult = $searchExecutor.ExecuteQuery($keywordQuery) $MyctxTemp.ExecuteQuery() #$MyctxTemp.ExecuteQueryWithIncrementalRetry(5, 30000); #5 retries, with a base delay of 30 secs. Write-Host " - Item number into the function:", $ClientResult.Value[0].ResultRows.Count return $ClientResult.Value[0] } Catch [Exception] { Write-host " >>>> ERROR MESSAGE:", $_.Exception.Message -f Red Return $False } } # --------------------------------------------------------------------------------------------------------------- Function Get-All-Intranet-News-Published-ExportCSV($MyctxTemp, $MyspoRootwebTemp) { [System.Data.DataTable]$resultDataTable = new-object System.Data.DataTable("SGSWORLDNEWS") [System.Data.DataColumn]$titleCol = new-object System.Data.DataColumn("Title") [System.Data.DataColumn]$pathCol = new-object System.Data.DataColumn("Path") [System.Data.DataColumn]$RefinableDate00Col = new-object System.Data.DataColumn("RefinableDate00") [System.Data.DataColumn]$RefinableString00Col = new-object System.Data.DataColumn("RefinableString00") [System.Data.DataColumn]$RefinableString01Col = new-object System.Data.DataColumn("RefinableString01") [System.Data.DataColumn]$RefinableString03Col = new-object System.Data.DataColumn("RefinableString03") [System.Data.DataColumn]$CreatedByCol = new-object System.Data.DataColumn("CreatedBy") $resultDataTable.Columns.Add($titleCol) $resultDataTable.Columns.Add($pathCol) $resultDataTable.Columns.Add($RefinableDate00Col) $resultDataTable.Columns.Add($RefinableString00Col) $resultDataTable.Columns.Add($RefinableString01Col) $resultDataTable.Columns.Add($RefinableString03Col) $resultDataTable.Columns.Add($CreatedByCol) [int]$currentRowIndex = 0 $resultTable = Get-SearchResults $currentRowIndex $MyctxTemp Write-Host " >> Total Rows Include Duplicated:", $resultTable.TotalRowsIncludingDuplicates -ForegroundColor Red if(($resultTable -ne $null) -and ($resultTable.TotalRowsIncludingDuplicates -gt 0)) { while ($resultTable.TotalRowsIncludingDuplicates -gt $resultDataTable.Rows.Count) { foreach($resultRow in $resultTable.ResultRows) { [System.Data.DataRow]$myrow = $resultDataTable.NewRow() $myrow["Title"] = $resultRow["Title"] $myrow["Path"] = $resultRow["Path"] $myrow["RefinableDate00"] = $resultRow["RefinableDate00"] $myrow["RefinableString00"] = $resultRow["RefinableString00"] $myrow["RefinableString01"] = $resultRow["RefinableString01"] $myrow["RefinableString03"] = $resultRow["RefinableString03"] $myrow["CreatedBy"] = $resultRow["CreatedBy"] $resultDataTable.Rows.Add($myrow) } $currentRowIndex = $resultDataTable.Rows.Count $resultTable = $null $resultTable = Get-SearchResults $currentRowIndex $MyctxTemp if (($resultTable -ne $null) -and ($resultTable.TotalRowsIncludingDuplicates -gt 0)) { if ($resultTable.RowCount -le 0) { break } } else { break } } } [string] $totalResults = $resultDataTable.Rows.Count; Write-Host " >>>>> Table Items placed into Datatable: ", $totalResults -ForegroundColor Yellow Clear-Content $CSVFileName $outputline = '"NewsTitle";"PublicationDate";"NewsURL";"BusinessFunction";"NewsType";"PublishingAreaCountry";"NewsCreator";' Add-Content -Encoding UTF8 -Force $CSVFileName $outputline foreach($result in $resultDataTable.Rows) { if($result["RefinableDate00"] -ne "") { $TempString = $result["RefinableDate00"].split(';')[0] $PortalPublishingDate=[datetime]::ParseExact([string]$TempString, 'M/d/yyyy h:mm:ss tt', [CultureInfo]::InvariantCulture) #10/2/2018 10:00:00 PM Write-Host " ---------------------------------------- " Write-Host " ------>>> NewsPath:", $result["Path"] Write-Host " ------>>> Title:", $result["Title"] Write-Host " ------>>> RefinableDate00:", $result["RefinableDate00"] #$PortalPublishingDate Write-Host " ------>>> PublicationDate:", $PortalPublishingDate Write-Host " ------>>> BusinessFunction:", $result["RefinableString00"] Write-Host " ------>>> NewsType:", $result["RefinableString01"] Write-Host " ------>>> PublishingAreaCountry:", $result["RefinableString03"] Write-Host " ------>>> NewsCreator:", $result["CreatedBy"] Write-Host " ---------------------------------------- " #CSV file location, to store the result $outputline = '"'+ $result["Title"] +'";"'+ $PortalPublishingDate.ToString("dd.MM.yyyy") +'";"'+ $result["Path"] +'";"'+ $result["RefinableString00"] +'";"'+ $result["RefinableString01"] +'";"'+ $result["RefinableString03"] +'";"'+ $result["CreatedBy"] +'";' Add-Content -Encoding UTF8 -Force $CSVFileName $outputline } } } # --------------------------------------------------------------------------------------------------------------- Load-DLLandAssemblies #get and save your O365 credentials [string]$username = "loginadmin@yourtenant.onmicrosoft.com" [string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt" $secureStringPwd = ConvertTo-SecureString -string (Get-Content $PwdTXTPath) $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $secureStringPwd #connect to the web site using the stored credentials Write-host " " Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green Write-host " ---- CONNECT THE SITE --- " -ForegroundColor green Write-host " CONNECTED SITE:", $SitePagesURL -ForegroundColor Yellow $Myctx = New-Object Microsoft.SharePoint.Client.ClientContext($SitePagesURL +"/intranet") $Myctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName,$cred.Password) $Myctx.RequestTimeout = 1000000 # milliseconds $MyspoRootweb = $Myctx.Web $Myctx.Load($MyspoRootweb) $Myctx.ExecuteQuery() Write-Host " " Write-Host " ---------------------------------------------------------" Write-Host " >>>> # Server Version:" $Myctx.ServerVersion " # <<<<<<" -ForegroundColor Green Write-Host " ---------------------------------------------------------" Write-Host " " Write-host " -------------------------------------------------------- " Write-host " -->> RootSite:", $MyspoRootweb.URL -ForegroundColor green Write-host " " Get-All-Intranet-News-Published-ExportCSV $Myctx $MyspoRootweb The solution was used on my production site with thousands of news published and give us now statistics for the last years of that Intranet site. Fabrice Romelard French version of that message: http://blogs.developpeur.org/fabrice69/archive/2018/11/06/sharepoint-extraire-les-pages-publi-es-dans-un-site-de-publishing-en-csv.aspx The source sites used to build that script are: https://blogs.msdn.microsoft.com/vesku/2014/08/26/system-update-for-sharepoint-list-items-using-app-model/ https://techcommunity.microsoft.com/t5/SharePoint/How-to-change-Modern-page-Author-from-the-quot-Created-By-quot/m-p/220432#M20147 https://sharepoint.stackexchange.com/questions/129926/extract-email-from-listitem-user https://www.c-sharpcorner.com/article/office-365-sharepoint-online-powershell-script-to-call-search-api-and-get-th/ https://sharepoint.stackexchange.com/questions/208462/sharepoint-search-js-returns-only-500-search-results http://www.thesharepointguide.com/sharepoint-search-how-to-return-all-results/ https://www.spjeff.com/2015/04/21/datatable-in-powershell-for-crazy-fast-filters/4KViews1like0CommentsHow to join the 2 SharePoint News World - Old Publishing site and Modern Teamsite
The SharePoint solution is changing since some years and Microsoft is moving fast to implement the Modern capabilities in all the SharePoint components. In the past, the Intranet site was built for most of the case, using the Publishing sites (technology existing since many years, probably SP 2003 for a large part), but today, the best solution could be to focus on the Communication sites associated with the modern sites. The problem is now with the existing Corporate sites running a huge solution based on the SharePoint Publishing: How to show my Publishing News into the Basic Office 365 SharePoint app (mobile or Web) ? A solution could be the usage of the "Repost Page". What is the Repost Page: That "Repost Page" is a dedicated Page layout used into the Modern Page, showing the user the news published in another Teamsite (cf. Communication Hub Site to understand the logic). The Hub Site is creating this without any user action, but anyone with the contribution access into a modern teamsite can create a "Repost Page" (named "News Link") to republish into his teamsite something published initially somewhere else (like the Retweet). It could be a link into the SharePoint, but also pointing anything else (Bing News for example). When you are clicking that link, the system will ask you to put first the destination Link and after complete the Image, the title and the description When that creation is done, the "Repost Page" will be visible into the Modern News webpart like any other News page but also into the Global Tenant Root page: https://[YourTenant].sharepoint.com/_layouts/15/sharepoint.aspx> So you can dedicate someone to republish the Publishing News into a Modern Page Library using the Repost Page layout, but that will not be so nice for him, and the PowerShell script cold be a good idea to do that. PowerShell script to create the Repost Page: Based on the previous message published: How to create Repost Page (Modern Page Library) with PowerShell I created this script fully adapted to my case and has 3 functions: Get the last published news on the old portal based on the search engine and export it to CSV Load the CSV file to check if the repost page is yet existing (if not yet, create it) Change the metadata of the Modern Reports News to set the correct creator and author [string]$SitePagesURL ="https://YourTenant.sharepoint.com" [string]$PageLibPublicName = "Site Pages" [DateTime]$MyCSVPublishingDate = Get-Date [DateTime]$PortalPublishingDate = Get-Date [string]$MyCSVPublisher = "" [string]$MyCSVTitle = "" [string]$MyCSVNewsURL = "" [string]$MyCSVNewsPictureURL = "" [string]$MyCSVNewsDescription = "" [string]$CSVFileName = "ExportGlobalNewsItems.csv" [string]$NewsPageFileName = "" [string]$queryText = "ContentTypeId:0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00DAB155038B062847A409F1E450E9E5E3* Path:https://yourTenant.sharepoint.com/yourintranet " [string]$srcrpattern = '(?i)src="(.*?)"' [string]$outputline = "" [int]$TempUserID = 0 # --------------------------------------------------------------------------------------------------------------- function Load-DLLandAssemblies { [string]$defaultDLLPath = "" # Load assemblies to PowerShell session $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) $defaultDLLPath = "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.Online.SharePoint.Client.Tenant.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) $defaultDLLPath = "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client.Search\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Search.dll" #$defaultDLLPath = "D:\TOOLS\SHAREPOINT\SP_ONLINE\sharepointclientcomponents\microsoft.sharepointonline.csom.16.1.8119.1200\lib\net40-full\Microsoft.SharePoint.Client.Search.dll" [System.Reflection.Assembly]::LoadFile($defaultDLLPath) } # --------------------------------------------------------------------------------------------------------------- Function Get-All-Intranet-News-Published-ExportCSV($MyctxTemp, $MyspoRootwebTemp) { # add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM $keywordQuery = New-Object Microsoft.SharePoint.Client.Search.Query.KeywordQuery($MyctxTemp) $keywordQuery.QueryText = $queryText $keywordQuery.RowLimit = 50 $keywordQuery.TrimDuplicates=$false $keywordQuery.SelectProperties.Add("LastModifiedTime") $keywordQuery.SelectProperties.Add("Modified") $keywordQuery.SelectProperties.Add("ModifiedBy") $keywordQuery.SelectProperties.Add("IntranetPublisher") $keywordQuery.SelectProperties.Add("DescriptionResumeOWSTEXT") $keywordQuery.SelectProperties.Add("PublishingImage") $keywordQuery.SortList.Add("Modified","Desc") $searchExecutor = New-Object Microsoft.SharePoint.Client.Search.Query.SearchExecutor($MyctxTemp) $results = $searchExecutor.ExecuteQuery($keywordQuery) $MyctxTemp.ExecuteQuery() Write-Host $results.Value[0].ResultRows.Count Clear-Content $CSVFileName $outputline = '"NewsTitle";"PublisherEmail";"PublicationDate";"NewsURL";"NewsPictureURL";"NewsDescription";' Add-Content -Encoding UTF8 -Force $CSVFileName $outputline foreach($result in $results.Value[0].ResultRows) { $TempString = $result["Modified"].split(';')[0] $ImageURLsrc=([regex]$srcrpattern ).Matches($result["PublishingImage"]) | ForEach-Object { $_.Groups[1].Value } $ImageURLsrc=$SitePagesURL + $ImageURLsrc.split('?')[0] +"?RenditionID=9" $PortalPublishingDate=[datetime]::ParseExact([string]$TempString, 'M/d/yyyy h:mm:ss tt', [CultureInfo]::InvariantCulture) $PublisherDetails = $result["IntranetPublisher"].split('|') #Write-Host " ------>>> TempString:", $TempString #Write-Host " ------>>> PublisherDetails:", $PublisherDetails.Count, "- LastField:", $PublisherDetails[4].Trim() #Write-Host " ------>>> PublishingImage:", $result["PublishingImage"] #Write-Host " ------>>> Modified:", $result["Modified"] Write-Host " ---------------------------------------- " Write-Host " ------>>> NewsPath:", $result["Path"] Write-Host " ------>>> Title:", $result["Title"] Write-Host " ------>>> PublicationDate:", $PortalPublishingDate Write-Host " ------>>> IntranetPublisherEmail:", $PublisherDetails[4].Trim() Write-Host " ------>>> ImageURLsrc:", $ImageURLsrc Write-Host " ------>>> DescriptionResumeOWSTEXT:", $result["DescriptionResumeOWSTEXT"] Write-Host " ---------------------------------------- " #CSV file location, to store the result $outputline = '"'+ $result["Title"] +'";"'+ $PublisherDetails[4].Trim() +'";"'+ $PortalPublishingDate.ToString("dd.MM.yyyy hh:mm:ss") +'";"'+ $result["Path"] +'";"'+ $ImageURLsrc +'";"'+ $result["DescriptionResumeOWSTEXT"] +'";' Add-Content -Encoding UTF8 -Force $CSVFileName $outputline } } # --------------------------------------------------------------------------------------------------------------- Function Get-All-News-PageList-ComparedToCSV($MyctxTemp, $MyspoRootwebTemp) { $GlobalNewsPageCSV = Import-Csv -encoding UTF8 $CSVFileName -delimiter ";" $GlobalNewsPageCSV | Format-Table $Alllists = $MyspoRootwebTemp.Lists $MyPagelist = $Alllists.GetByTitle($PageLibPublicName) $MyPagelistItems = $MyPagelist.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery(9999)) $MyctxTemp.load($MyPagelistItems) $MyctxTemp.executeQuery() foreach($PageItem in $MyPagelistItems) { Write-Host "" Write-Host "" Write-Host " --------------------------------------------------------- " <# foreach($MyFieldval in $PageItem.FieldValues) { Write-Host " >>> FieldName:", $MyFieldval } #> $ModifiedByuser = $PageItem["Editor"] $CreatedByuser = $PageItem["Author"] Write-Host "ID:", $PageItem["ID"], "- Title:", $PageItem["Title"], "- Original Publication Date:", $PageItem["Modified"] Write-Host " ==>>> PromotedState:", $PageItem["PromotedState"], "- PageLayoutType:", $PageItem["PageLayoutType"] -ForegroundColor red Write-Host " ===> Modified by:", $ModifiedByuser.LookupValue, "[", $ModifiedByuser.LookupId, "] - Created by:", $CreatedByuser.LookupValue, "[", $CreatedByuser.LookupId, "]" Write-Host " >> _OriginalSourceUrl:", $PageItem["_OriginalSourceUrl"] -ForegroundColor magenta Write-Host " >> Description:", $PageItem["Description"] Write-Host " >> BannerImageUrl:", $PageItem["BannerImageUrl"].URL, "- URLDesc:", $PageItem["BannerImageUrl"].Description #[BannerImageUrl, Microsoft.SharePoint.Client.FieldUrlValue] Write-Host " >> ContentTypeId:", $PageItem["ContentTypeId"] # [ContentTypeId, 0x0101009D1CB255DA76424F860D91F20E6C4118002A50BFCFB7614729B56886FADA02339B00FB61AB42CC88E741A501DF164E1EDB74] $searchTerm = $PageItem["_OriginalSourceUrl"] $MyCSVPublishingDate = Get-Date $GlobalNewsPageCSV |Where-Object {$_.NewsURL -match $searchTerm} |foreach-object{ $MyCSVTitle=$_.NewsTitle; $MyCSVNewsURL=$_.NewsURL; $MyCSVPublisher=$_.PublisherEmail; $MyCSVPublishingDate=[datetime]::ParseExact($_.PublicationDate,'dd.MM.yyyy hh:mm:ss',$null) } if ($PageItem["_OriginalSourceUrl"] -eq $MyCSVNewsURL) { Write-Host " >>> CSV Title found:", $MyCSVTitle, "- CSV Publication Date:", $MyCSVPublishingDate, "- Publisher:", $MyCSVPublisher -ForegroundColor Yellow Write-Host " >> CSV NewsURL:", $MyCSVNewsURL -ForegroundColor magenta #Load Context for the target link page $PageItem["_OriginalSourceUrl"] $TempUri = new-object Uri($MyCSVNewsURL) [string]$TempserverRelativeURL = $TempUri.AbsolutePath [string]$MyTempSubWebURL = $MyCSVNewsURL.substring(0, $MyCSVNewsURL.IndexOf('Pages')) Write-Host " === >> MyTempSubWebURL:", $MyTempSubWebURL -ForegroundColor Yellow Write-Host " === >> TempserverRelativeURL:", $TempserverRelativeURL -ForegroundColor Yellow $MyDestinationPagectx = New-Object Microsoft.SharePoint.Client.ClientContext($MyTempSubWebURL) $MyDestinationPagectx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName,$cred.Password) $MyDestinationPagectx.RequestTimeout = 1000000 # milliseconds $MyDestinationPageweb = $MyDestinationPagectx.Web $MyDestinationPageSiteColl = $MyDestinationPagectx.Site $MyDestinationPagelist = $MyDestinationPageweb.Lists.GetByTitle("Pages") $MyDestinationPageFile = $MyDestinationPageweb.GetFileByServerRelativeUrl($TempserverRelativeURL); $MyDestinationPageFileitem = $MyDestinationPageFile.ListItemAllFields; $MyDestinationPagectx.Load($MyDestinationPageweb) $MyDestinationPagectx.Load($MyDestinationPageSiteColl) $MyDestinationPagectx.Load($MyDestinationPagelist) $MyDestinationPagectx.Load($MyDestinationPageFileitem) $MyDestinationPagectx.ExecuteQuery() Write-Host " === >> DestinationPage Site URL:", $MyDestinationPageSiteColl.Url, "- ID:", $MyDestinationPageSiteColl.ID -ForegroundColor white Write-Host " === >> DestinationPage Web URL:", $MyDestinationPageweb.Url, "- ID:", $MyDestinationPageweb.ID -ForegroundColor white Write-Host " === >> DestinationPage PageList Title:", $MyDestinationPagelist.Title, "- ID:", $MyDestinationPagelist.ID -ForegroundColor white Write-Host " === >> DestinationPage PageFile Title:", $MyDestinationPageFileitem["Title"].ToString(), "- ID:", $MyDestinationPageFileitem["UniqueId"].ToString() $MyEditoruserAccount = $MyspoRootwebTemp.EnsureUser("i:0#.f|membership|$($MyCSVPublisher)"); $MyctxTemp.load($MyEditoruserAccount) $MyctxTemp.executeQuery() Write-Host " ===> Modified Account Login:", $MyEditoruserAccount.LoginName -ForegroundColor Magenta $PageItem["Created_x0020_By"] = $MyEditoruserAccount.LoginName $PageItem["Modified_x0020_By"] = $MyEditoruserAccount.LoginName $PageItem["PromotedState"] = "2" $PageItem["PageLayoutType"] = "RepostPage" $PageItem["ClientSideApplicationId"] = "b6917cb1-93a0-4b97-a84d-7cf49975d4ec" $PageItem["_OriginalSourceSiteId"] = $MyDestinationPageSiteColl.ID $PageItem["_OriginalSourceWebId"] = $MyDestinationPageweb.ID $PageItem["_OriginalSourceListId"] = $MyDestinationPagelist.ID $PageItem["_OriginalSourceItemId"] = $MyDestinationPageFileitem["UniqueId"].ToString() $PageItem["Modified"] = $MyCSVPublishingDate; $PageItem["Created"] = $MyCSVPublishingDate; $PageItem["FirstPublishedDate"] = $MyCSVPublishingDate; $PageItem["Editor"] = $MyEditoruserAccount.Id; $PageItem["Author"] = $MyEditoruserAccount.Id $PageItem.Update() $MyctxTemp.ExecuteQuery() } else { Write-Host " >>> CSV Title not found:", $MyCSVTitle, "- Date:", $MyCSVPublishingDate, "- Publisher:", $MyCSVPublisher -ForegroundColor Red Write-Host " >> CSV NewsURL:", $MyCSVNewsURL -ForegroundColor Red } Write-Host " --------------------------------------------------------- " } } Function Get-All-CSVNews-ComparedToPageList($MyctxTemp, $MyspoRootwebTemp) { $GlobalNewsPageCSV = Import-Csv -encoding UTF8 $CSVFileName -delimiter ";" $GlobalNewsPageCSV | Format-Table foreach($CSVItem in $GlobalNewsPageCSV) { Write-Host " --------------------------------------------------------- " Write-Host " >> CSV NewsTitle:", $CSVItem.NewsTitle Write-Host " >> CSV NewsURL:", $CSVItem.NewsURL Write-Host " >> CSV PublisherEmail:", $CSVItem.PublisherEmail Write-Host " >> CSV PublicationDate:", $CSVItem.PublicationDate Write-Host " >> CSV NewsPictureURL:", $CSVItem.NewsPictureURL Write-Host " >> CSV NewsDescription:", $CSVItem.NewsDescription $MyCSVTitle = $CSVItem.NewsTitle $MyCSVNewsURL = $CSVItem.NewsURL $MyCSVPublisher = $CSVItem.PublisherEmail $MyCSVPublishingDate = [datetime]::ParseExact($CSVItem.PublicationDate,'dd.MM.yyyy hh:mm:ss',$null) $MyCSVNewsPictureURL = $CSVItem.NewsPictureURL $MyCSVNewsDescription = $CSVItem.NewsDescription #Load Context for the target link page $PageItem["_OriginalSourceUrl"] $TempUri = new-object Uri($MyCSVNewsURL) [string]$TempserverRelativeURL = $TempUri.AbsolutePath [string]$MyTempSubWebURL = $MyCSVNewsURL.substring(0, $MyCSVNewsURL.IndexOf('Pages')) Write-Host " === >> MyTempSubWebURL:", $MyTempSubWebURL -ForegroundColor Yellow Write-Host " === >> TempserverRelativeURL:", $TempserverRelativeURL -ForegroundColor Yellow $MyDestinationPagectx = New-Object Microsoft.SharePoint.Client.ClientContext($MyTempSubWebURL) $MyDestinationPagectx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName,$cred.Password) $MyDestinationPagectx.RequestTimeout = 1000000 # milliseconds $MyDestinationPageweb = $MyDestinationPagectx.Web $MyDestinationPageSiteColl = $MyDestinationPagectx.Site $MyDestinationPagelist = $MyDestinationPageweb.Lists.GetByTitle("Pages") $MyDestinationPageFile = $MyDestinationPageweb.GetFileByServerRelativeUrl($TempserverRelativeURL); $MyDestinationPageFileitem = $MyDestinationPageFile.ListItemAllFields; $MyDestinationPagectx.Load($MyDestinationPageweb) $MyDestinationPagectx.Load($MyDestinationPageSiteColl) $MyDestinationPagectx.Load($MyDestinationPagelist) $MyDestinationPagectx.Load($MyDestinationPageFileitem) $MyDestinationPagectx.ExecuteQuery() Write-Host " === >> DestinationPage Site URL:", $MyDestinationPageSiteColl.Url, "- ID:", $MyDestinationPageSiteColl.ID -ForegroundColor white Write-Host " === >> DestinationPage Web URL:", $MyDestinationPageweb.Url, "- ID:", $MyDestinationPageweb.ID -ForegroundColor white Write-Host " === >> DestinationPage PageList Title:", $MyDestinationPagelist.Title, "- ID:", $MyDestinationPagelist.ID -ForegroundColor white Write-Host " === >> DestinationPage PageFile Title:", $MyDestinationPageFileitem["Title"].ToString(), "- ID:", $MyDestinationPageFileitem["UniqueId"].ToString() $MyEditoruserAccount = $MyspoRootwebTemp.EnsureUser("i:0#.f|membership|$($MyCSVPublisher)"); $MyctxTemp.load($MyEditoruserAccount) $MyctxTemp.executeQuery() $MyPagelist = $MyspoRootwebTemp.Lists.GetByTitle($PageLibPublicName) $MyQuery = New-Object Microsoft.SharePoint.Client.CamlQuery; $MyQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name='_OriginalSourceUrl' /><Value Type='Text'>$MyCSVNewsURL</Value></Eq></Where></Query></View>" $MyPagelistItems = $MyPagelist.GetItems($MyQuery); $MyctxTemp.Load($MyPagelistItems) $MyctxTemp.ExecuteQuery() if($MyPagelistItems.Count -lt 1) { [string]$NewsPageFileName = "/yourintranet/SitePages/"+ $MyCSVPublishingDate.ToString("yyyyMMdd") +'-'+ $CSVItem.NewsURL.Substring($CSVItem.NewsURL.LastIndexOf("/") + 1) Write-Host " >> $($MyPagelistItems.Count) PageList Item Found, Need to be created [ $NewsPageFileName ]" -ForegroundColor Red # TO CREATE !!! $NewPageitem = $MyPagelist.RootFolder.Files.AddTemplateFile($NewsPageFileName, [Microsoft.SharePoint.Client.TemplateFileType]::ClientSidePage).ListItemAllFields # Make this page a "modern" page $NewPageitem["ContentTypeId"] = "0x0101009D1CB255DA76424F860D91F20E6C4118002A50BFCFB7614729B56886FADA02339B00874A802FBA36B64BAB7A47514EAAB232"; $NewPageitem["PageLayoutType"] = "RepostPage" $NewPageitem["PromotedState"] = "2" $NewPageitem["Title"] = $CSVItem.NewsTitle $NewPageitem["ClientSideApplicationId"] = "b6917cb1-93a0-4b97-a84d-7cf49975d4ec" $NewPageitem["_OriginalSourceSiteId"] = $MyDestinationPageSiteColl.ID $NewPageitem["_OriginalSourceWebId"] = $MyDestinationPageweb.ID $NewPageitem["_OriginalSourceListId"] = $MyDestinationPagelist.ID $NewPageitem["_OriginalSourceItemId"] = $MyDestinationPageFileitem["UniqueId"].ToString() $NewPageitem["_OriginalSourceUrl"] = $MyCSVNewsURL $NewPageitem["Editor"] = $MyEditoruserAccount.Id $NewPageitem["Author"] = $MyEditoruserAccount.Id $NewPageitem["Description"] = $MyCSVNewsDescription $NewPageitem["BannerImageUrl"] = $MyCSVNewsPictureURL; $NewPageitem["Modified"] = $MyCSVPublishingDate; $NewPageitem["Created"] = $MyCSVPublishingDate; $NewPageitem["Created_x0020_By"] = $MyEditoruserAccount.LoginName $NewPageitem["Modified_x0020_By"] = $MyEditoruserAccount.LoginName $NewPageitem["FirstPublishedDate"] = $MyCSVPublishingDate; $NewPageitem.Update(); $MyctxTemp.Load($NewPageitem); $MyctxTemp.ExecuteQuery(); } elseif($MyPagelistItems.Count -eq 1) { Write-Host " >> $($MyPagelistItems.Count) Page Item Found, Case OK !!!" -ForegroundColor Yellow # TO CHECK AND UPDATE VIA SCRIPT !!! #Loop through each item (only one if that is OK) $MyPagelistItems | ForEach-Object { #Get the Title field value Write-Host " >> PageList NewsTitle:", $_["Title"] -ForegroundColor Yellow Write-Host " >> PageList NewsUrl:", $_["_OriginalSourceUrl"] -ForegroundColor Yellow if($MyCSVNewsPictureURL -ne $_["BannerImageUrl"].URL) { $_["BannerImageUrl"].URL = $MyCSVNewsPictureURL $_["BannerImageUrl"].Description = $MyCSVNewsPictureURL } $_["PromotedState"] = "2" $_["Modified"] = $MyCSVPublishingDate; $_["Created"] = $MyCSVPublishingDate; $_["FirstPublishedDate"] = $MyCSVPublishingDate; $_["_OriginalSourceSiteId"] = $MyDestinationPageSiteColl.ID $_["_OriginalSourceWebId"] = $MyDestinationPageweb.ID $_["_OriginalSourceListId"] = $MyDestinationPagelist.ID $_["_OriginalSourceItemId"] = $MyDestinationPageFileitem["UniqueId"].ToString() $_["Editor"] = $MyEditoruserAccount.Id; $_["Author"] = $MyEditoruserAccount.Id $_["Created_x0020_By"] = $MyEditoruserAccount.LoginName $_["Modified_x0020_By"] = $MyEditoruserAccount.LoginName $_.Update() $MyctxTemp.ExecuteQuery() } } else { Write-Host " >> $($MyPagelistItems.Count) PageList Item Found, Need to be fixed !!!" -ForegroundColor Red # TO CHECK AND CONTROL MANUALLY !!! $MyPagelistItems | ForEach-Object { #Get the Title field value Write-Host " >> PageList NewsTitle:", $_["Title"] -ForegroundColor Yellow Write-Host " >> PageList NewsUrl:", $_["_OriginalSourceUrl"] -ForegroundColor Yellow } } } } # --------------------------------------------------------------------------------------------------------------- Load-DLLandAssemblies #get and save your O365 credentials [string]$username = "AdminAccount@Yourtenant.onmicrosoft.com" [string]$PwdTXTPath = "C:\SECUREDPWD\ExportedPWD-$($username).txt" $secureStringPwd = ConvertTo-SecureString -string (Get-Content $PwdTXTPath) $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $secureStringPwd #connect to the web site using the stored credentials Write-host " " Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green Write-host " ---- CONNECT THE SITE --- " -ForegroundColor green Write-host " CONNECTED SITE:", $SitePagesURL -ForegroundColor Yellow $Myctx = New-Object Microsoft.SharePoint.Client.ClientContext($SitePagesURL +"/yourintranet") $Myctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName,$cred.Password) $Myctx.RequestTimeout = 1000000 # milliseconds $MyspoRootweb = $Myctx.Web $Myctx.Load($MyspoRootweb) $Myctx.ExecuteQuery() Write-Host " " Write-Host " ---------------------------------------------------------" Write-Host " >>>> # Server Version:" $Myctx.ServerVersion " # <<<<<<" -ForegroundColor Green Write-Host " ---------------------------------------------------------" Write-Host " " Write-host " -------------------------------------------------------- " Write-host " -->> RootSite:", $MyspoRootweb.URL -ForegroundColor green Write-host " " Get-All-Intranet-News-Published-ExportCSV $Myctx $MyspoRootweb Get-All-CSVNews-ComparedToPageList $Myctx $MyspoRootweb Get-All-News-PageList-ComparedToCSV $Myctx $MyspoRootweb You can easily modify it with your own requirements, but I use it now to enrich the last 500 published news into the modern library, and that was working perfectly. Fabrice Romelard French version: SharePoint: Comment Utiliser les Modern Pages dans un Site Intranet basé sur le Publishing site4.1KViews4likes0CommentsCustomising the search box Ui in SharePoint 2016
Hi I have been asked to improve the appearance of a search box that is centrally ( don't ask!) situated on a SharePoint 2016 publishing site landing page. I can toggle with Search box web part settings to switch between search center and a custom search results page: Here the issue is how do I change the height as it looks a bit odd on the page :-( With the custom results page option issue is conversely, the width - the entire web part zone is filled! Ideally I want the users to have a consistent search experience on the intranet so I am thinking I should go for the first option. Therefore, If the problem is a CSS style that is being overridden then any pointers will be useful Note, there is an underlying (archaic) custom responsive master page + CSS +JS which I do want to replace once the business is happy with the searching capability. I am thinking of the Enable-PnPResponsiveUI --> Classic Team Site (STS#0) but still need to deal responsive UI Page Layouts.2.7KViews0likes3Comments