Skip to content

Commit

Permalink
fix reference to Site Pages to use Title
Browse files Browse the repository at this point in the history
  • Loading branch information
dcashpeterson committed Jul 14, 2023
1 parent c733f80 commit 15185eb
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions installation/M365lpConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ if (-not (Get-Module -ListAvailable -Name PnP.PowerShell )) {
Write-Warning "`nInstall-Module PnP.PowerShell`n"
Write-Warning "`nInstall-Module SharePointPnPPowerShellOnline`n"
return
} else {
}
else {
Import-Module -Name SharePointPnPPowerShellOnline -DisableNameChecking
$moduleUsed = "SharePointPnPPowerShellOnline"
}

} else {
}
else {
Import-Module -Name PnP.PowerShell -DisableNameChecking
$moduleUsed = "PnP.PowerShell"
}
Expand Down Expand Up @@ -70,15 +72,18 @@ try {
if (-not [string]::IsNullOrWhitespace($Credentials)) {
if ($moduleUsed -eq "SharePointPnPPowerShellOnline") {
SharePointPnPPowerShellOnline\Connect-PnPOnline -Url $clSite -Credentials $Credentials -ErrorAction Stop
} else {
}
else {
PnP.PowerShell\Connect-PnPOnline -Url $clSite -Credentials $Credentials -ErrorAction Stop
}

} else {
}
else {
# If not, prompt for authentication. This supports MFA
if ($moduleUsed -eq "SharePointPnPPowerShellOnline") {
SharePointPnPPowerShellOnline\Connect-PnPOnline -Url $clSite -UseWebLogin -ErrorAction Stop
} else {
}
else {
PnP.PowerShell\Connect-PnPOnline -Url $clSite -Interactive -ErrorAction Stop
}
}
Expand Down Expand Up @@ -138,8 +143,8 @@ if ($SiteAdmin) {
Write-Warning "Could not find `"Microsoft 365 learning pathways`" app. Please install in it your app catalog and run this script again."
break
}
$sitePagesList = Get-PnPList -Identity "SitePages"
if($null -ne $sitePagesList) {
$sitePagesList = Get-PnPList -Identity "Site Pages"
if ($null -ne $sitePagesList) {
# Delete pages if they exist. Alert user.
$clv = Get-PnPListItem -List $sitePagesList -Query "<View><Query><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='Text'>CustomLearningViewer.aspx</Value></Eq></Where></Query></View>"
if ($null -ne $clv) {
Expand Down Expand Up @@ -194,7 +199,8 @@ if ($SiteAdmin) {
$cla["PageLayoutType"] = "SingleWebPartAppPage"
$cla.Update()
Invoke-PnPQuery # Done with the Admin page
} else {
}
else {
# Now create the page whether it was there before or not
$clvPage = Add-PnPPage "CustomLearningViewer" # Will fail if user can't write to site collection
$clvSection = Add-PnPPageSection -Page $clvPage -SectionTemplate OneColumn -Order 1
Expand All @@ -204,7 +210,7 @@ if ($SiteAdmin) {
Write-Host "." -NoNewline
$WebPartsFound = $false
while ($stopwatch.elapsed -lt $timeout) {
if (Get-PnPPageComponent -page CustomLearningViewer.aspx -ListAvailable | Where-Object {$_.Name -eq "Microsoft 365 learning pathways administration"}) {
if (Get-PnPPageComponent -page CustomLearningViewer.aspx -ListAvailable | Where-Object { $_.Name -eq "Microsoft 365 learning pathways administration" }) {
Write-Host "Microsoft 365 learning pathways web parts found"
$WebPartsFound = $true
break
Expand Down

0 comments on commit 15185eb

Please sign in to comment.