Oct 17 2018 03:21 AM - edited Oct 17 2018 03:54 AM
In some case, it could be useful to use the Modern Pages into the Help site pages.
The previous generic case proposed was the Wiki Site with Wiki Pages.
Advantage to use the Modern Pages
In SharePoint Online the implementation of the modern pages propose many features useful and simplifying the end user navigation:
It's really a basic to match with the Microsoft Strategy and the Wiki Site/Page is not anymore part of it.
Business Case presentation
This solution is matching with a dedicated requirement I had:
The CSV file need to have only the following entries (columns):
A generic picture per topic need to be placed into the current SiteAsset library with the name "$(CHECKTOPIC).JPG".
When the Script is executed the responsible of the Checklist have to edit each page to complete the content into the different parts like:
-------------------------------
Get all the data from the business line to be sure the mission is ready to start
-------------------------------------
PowerShell script:
You can use that script and adapt it to your specific case as you want, it's only a base to use.
$HelpAndQAUrl = "https://[YourTenant].sharepoint.com/sites/SiteCollection/helpsite" $CSVFilePath = "C:\Business-CheckList.csv" ##Connecting to site - get and save your O365 credentials [string]$username = "Admin@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 # --------------------------------------------------------------------------------------------------------------- [string]$TextTemplateToPut = "" [string]$pageFilename = "" [string]$pageFileTitle = "" [string]$PageTopic = "" [string]$PageTitleFull = "" [string]$pageFilename = "" [string]$PageTitleToUpdate = "" [int]$ParentNodeID = 0 [int]$PageNodeID = 0 # --------------------------------------------------------------------------------------------------------------- #GET CSV File $AllPagesToCreate = Import-Csv -Path $CSVFilePath # -------------------------------------------------------------------------------------------- #Loop for each line foreach ($PageToCreate in $AllPagesToCreate) { # --------------------------------------------------------------------------------------------------------------- Write-host " ==> Page ID", $PageToCreate.CHECKID, "- Name:", $PageToCreate.CHECKNAME , "- Topic:", $PageToCreate.CHECKTOPIC -ForegroundColor Yellow # --------------------------------------------------------------------------------------------------------------- $pageFileTitle = $PageToCreate.CHECKID $PageTopic = $PageToCreate.CHECKTOPIC $PageTitleFull = $PageToCreate.CHECKNAME if($PageTitleFull.IndexOf("(") -gt 0) { $PageTitleShort = $PageTitleFull.Substring(0, $PageTitleFull.IndexOf("(")) } else { $PageTitleShort = $PageTitleFull } $pageFilename = -join($pageFileTitle, ".aspx") $TextTemplateToPut = "<h2>Task Title: $($PageTitleFull)</h2>" $TextTemplateToPut += "<h3>Topic:</h3><ul><li>$($PageTopic)</li></ul>" $TextTemplateToPut += "<h3>Description:</h3><p> </p><p> </p>" $TextTemplateToPut += "<h3>Estimated Time:</h3><ul><li> </li></ul>" $TextTemplateToPut += "<h3>Person in charge:</h3><ul><li> </li></ul>" $TextTemplateToPut += "<h3>Starting time:</h3><ul><li> </li></ul><p> </p>" $PageTitleToUpdate = -join($pageFileTitle, " - ", $PageTitleShort) $ParentNodeID = 0 $PageNodeID = 0 Write-host " " Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green Write-host " ---- START THE PAGE CREATION:", $pageFileTitle, "-", $pageFilename -ForegroundColor green Write-host " ---- Page Title Full:", $PageTitleFull -ForegroundColor green Write-host " ---- Page Title Short:", $PageTitleShort -ForegroundColor green Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green # --------------------------------------------------------------------------------------------------------------- #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:", $HelpAndQAUrl -ForegroundColor Yellow Connect-PnPOnline -Url $HelpAndQAUrl -Credential $cred Write-host " -------------------------------------------------------------------------------------------- " -ForegroundColor green $checkpage = Get-PnPClientSidePage -Identity $pageFilename -ErrorAction SilentlyContinue if($checkpage -eq $null) { Write-Host " >>> Page does not exist or is not modern" $page = Add-PnPClientSidePage -Name $pageFilename -LayoutType "Article" } else { Write-Host " >>> We have a modern page present" $page = $checkpage } #Add text webpart to page Add-PnPClientSideText -Page $page -Text $TextTemplateToPut Set-PnPClientSidePage -Identity $page -LayoutType "Article" -Title $PageTitleToUpdate $page = Get-PnPClientSidePage -Identity $pageFilename -ErrorAction SilentlyContinue Write-host " ==>> PAGE HEADERS ImageServerRelativeUrl:", $page.PageHeader.ImageServerRelativeUrl -ForegroundColor Green $ctx = Get-PnPContext Write-host " ==>> WEB Relative URL:", $ctx.Web.ServerRelativeUrl -ForegroundColor Yellow $mySiteRelativeURL = $ctx.Web.ServerRelativeUrl $myPageRelativeURL = -join($mySiteRelativeURL, "/", $page.PagesLibrary, "/", $pageFilename) Write-host " ==>> PAGE Relative URL:", $myPageRelativeURL -ForegroundColor Yellow $page.PageHeader.ImageServerRelativeUrl = $mySiteRelativeURL +"/SiteAssets/$($PageTopic).JPG" $page.Save() $page.Publish() Get-PnPConnection $AllQuicklaunchNodes = Get-PnPNavigationNode foreach($MyNode in $AllQuicklaunchNodes) { if($MyNode.Title -eq $PageTopic) { Write-host " ->>>> PARENT - MenuNode Title:", $MyNode.Title, "- ID:", $MyNode.ID -ForegroundColor Yellow $ParentNodeID = $MyNode.ID } else { Write-host " - MenuNode Title:", $MyNode.Title, "- ID:", $MyNode.ID -ForegroundColor Green } } if($ParentNodeID -eq 0) { Write-host " ===>>>> TOPIC LINK NOT EXIST, Need to create it" -ForegroundColor Red $AddMyNode = Add-PnPNavigationNode -Title $PageTopic -Url $mySiteRelativeURL -Location "QuickLaunch" $ParentNodeID = $AddMyNode.Id } $Topicnodes = Get-PnPNavigationNode -Id $ParentNodeID foreach($MyPageNode in $Topicnodes.Children) { if($MyPageNode.Title -eq $PageTitleToUpdate) { Write-host " ->>>> PAGE NODE EXIST- MenuNode Title:", $MyPageNode.Title, "- ID:", $MyPageNode.ID -ForegroundColor Red $PageNodeID = $MyPageNode.ID } else { Write-host " ->>>> PAGE NODE - MenuNode Title:", $MyPageNode.Title, "- ID:", $MyPageNode.ID -ForegroundColor green } } if($PageNodeID -eq 0) { $AddMyNode = Add-PnPNavigationNode -Title $PageTitleToUpdate -Url $myPageRelativeURL -Location "QuickLaunch" -Parent $ParentNodeID } }
Visual Result:
The home page of the Help Site can be configured with the Modern News WebPart to display the last published help pages:
And for one of the page, you can retrieve the content with that basic display:
Post execution step:
When the site is created and after the task owner enrich the content into the pages, you can use that other script to update the Page Metadata setting the author field and publication date adapted with real information of the Page Owner and not your admin account:
Conclusion
This script was used for many internal sites to create some site with hundreds of pages.
Romelard Fabrice
French version:
Nov 14 2018 12:04 AM
Nov 19 2018 07:22 AM
I'm not sure to understand the point
The best way is to send me a direct email and I will try to respond to (in French better)
Fab