How to join the 2 SharePoint News World - Old Publishing site and Modern Teamsite

Steel Contributor

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).Repost Page manual creationRepost Page manual creation

 

 

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 descriptionCreate a repost page manuallyCreate a repost page manually

 

 

When that creation is done, the "Repost Page" will be visible into the Modern News webpart like any other News pageModern News WebPartModern News WebPart

 

 

but also into the Global Tenant Root page:

  • https://[YourTenant].sharepoint.com/_layouts/15/sharepoint.aspx>

SharePoint Root Tenant homepageSharePoint Root Tenant homepage

 

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:

 

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:

0 Replies