Bienvenue à Blogs CodeS-SourceS Identification | Inscription | Aide

Blog Technique de Romelard Fabrice

Les dernières Actualités de Romelard Fabrice (Alias fabrice69 ou F___) principalement autour des technologies Microsoft

Actualités

  • Toutes les actualités et informations sur les technologies Microsoft principalement autour de .NET et SQL Server

Archives

Office 365: Comment Utiliser les Modern Pages dans un Site Intranet SharePoint basé sur le Publishing site

Microsoft est plus rapide que les organisations dans son changement de stratégie et le passage de toute la solution SharePoint à la sauce Moderne entraine quelques soucis.

En effet, de nombreuses organisations ont créées des Sites Intranet Corporate basés sur la technologie des Publishing Site qui n’est pas supportée par les automatismes actuellement implémentés par Microsoft.

Donc la question vient très rapidement:

  • Comment intégrer les News de mon site Intranet dans les applications basiques Office 365 SharePoint (Mobile ou Web) ?

Pour répondre à cette question, une solution peut être le passage par les Repost Pages

Qu’est-ce qu’un “Repost Page”

Ce type de page est basé sur la technologies des pages Modernes utilisant un Layout spécifique.

Cette logiques est d’ailleurs visible dans les Communication Hub Sites qui permettent d’aggéger les “News” de plusieurs sites dans un seul endroit et ceci sans aucune action du content manager (on retrouve la logique du “Retweet”).

Pour créer un Repost page manuallement, on peut aller dans un site modern et cliquer sur “Add > News Link”

Capture-RepostPage-01

Ce lien peut pointer vers n’importe quoi, même une page publique Bing News par exemple.

On doit fournir à cet instant l’adresse Web de la page à lier, puis un titre, une description et une image associée

Capture-RepostPage-02

Lorsque le formulaire est complété, la page repost apparait comme n’importe quelle News dans la WebPart des News du site (ou Hubsite)

Capture-RepostPage-03

Mais aussi dans la page racine du Tenant:

Capture-RepostPage-04

Vous pouvez donc simplement dédier une personne en charge de la création de ces “Repost Pages”, mais cela sera vraiment peu passionant pour cette personne.

La seconde option est d’adapter et d’utiliser le script PowerShell pour cela.

Script PowerShell créant les Repost Page pointant les news des Publishing Site

Basé sur un autre message publié ici:

J’ai donc créé le script siuvant permettant de:

  • Collecter les dernières news publiées sur le Site de Publishing en utilisant le Search et exportant la liste en CSV
  • Charger ce CSV pour vérifier si un Repost Page existe, sinon le créer
  • Changer les Metadata de chaque repost page avec les données du CSV

[string]$SitePagesURL ="
[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 = "$MyCSVNewsURL"
        $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


Vous pouvez facilement reprendre ce script et l’adapter à vos propres besoins, mais celui-ci a été validé en chargeant les 500 dernières News globales publiées sur notre Intranet Corporate sans aucun soucis.

Romelard Fabrice

Version en Anglais:

Ce post vous a plu ? Ajoutez le dans vos favoris pour ne pas perdre de temps à le retrouver le jour où vous en aurez besoin :
Posted: mardi 16 octobre 2018 15:34 par ROMELARD Fabrice

Commentaires

Pas de commentaires

Les commentaires anonymes sont désactivés

Les 10 derniers blogs postés

- Retrouvez-moi aux Microsoft experiences18 ! par Blog de Jérémy Jeanson le 11-06-2018, 22:25

- Office 365: Script PowerShell pour extraire les Teams associés à un utilisateur spécifié par Blog Technique de Romelard Fabrice le 11-06-2018, 13:37

- SharePoint: Extraire les pages publiées dans un site de publishing en CSV par Blog Technique de Romelard Fabrice le 11-06-2018, 11:04

- Office 365: Comment créer un jeu de Pages Modernes dans un Modern Site SharePoint Online en utilisant PowerShell depuis un fichier CSV par Blog Technique de Romelard Fabrice le 10-17-2018, 12:50

- Office 365: Comment Utiliser les Modern Pages dans un Site Intranet SharePoint basé sur le Publishing site par Blog Technique de Romelard Fabrice le 10-16-2018, 15:34

- Office 365: Comment changer le nom “Auteur” dans les pages modernes d'un Modern Site SharePoint Online par Blog Technique de Romelard Fabrice le 10-16-2018, 15:07

- Reprise des articles Codes-Sources de 2011 à 2013 par Blog de Jérémy Jeanson le 08-21-2018, 16:08

- Office 365: Modifier les jeux de couleur dans les Thèmes des pages classiques de SharePoint Online par Blog Technique de Romelard Fabrice le 08-08-2018, 17:27

- Office 365: Modifier les jeux de couleur dans les Thèmes des pages modernes de SharePoint Online par Blog Technique de Romelard Fabrice le 07-04-2018, 13:26

- Office 365: Script PowerShell pour fixer le Quota Warning de toutes les collections d’un tenant par Blog Technique de Romelard Fabrice le 07-03-2018, 14:16