Skip to content

Instantly share code, notes, and snippets.

@navarrorc
Created March 30, 2020 16:42
Show Gist options
  • Save navarrorc/b48cf279457fea1a4af77cc5b72f5f83 to your computer and use it in GitHub Desktop.
Save navarrorc/b48cf279457fea1a4af77cc5b72f5f83 to your computer and use it in GitHub Desktop.
Sample Runbook written in powershell
param(
[OutputType([string[]])]
[Parameter(Mandatory=$true)]
[string]
$SPOSiteUrl
)
Connect-PnPOnline -url $SPOSiteUrl -AppId 05f5eb20-13c1-4ce6-a992-bf697f03740a -AppSecret iCdfbFvD/mzkxvOH2JgY1afbZ6mf0zaDK+W3uzaNs8o=
$web = Get-PnPWeb
# $setHomePage = Set-PnPClientSidePage -Identity "Home" -CommentsEnabled:$false -LayoutType Home -HeaderType None -Publish
# Add or update items to BrandingSettings
$List = Get-PnPList -Web $web -Identity "BrandingSettings"
$data = @(
[pscustomobject]@{Name="cssURL";Value="/sites/cts/Style Library/TeamSite/assets/main-bundle.css"}
[pscustomobject]@{Name="vendorsURL";Value="/sites/cts/Style Library/TeamSite/assets/vendors~main-bundle.js"}
[pscustomobject]@{Name="scriptURL";Value="/sites/cts/Style Library/TeamSite/assets/main-bundle.js"}
)
foreach ($item in $data) {
$Name = $item.Name
$Value = $item.Value
# Find list item
$item = Get-PnPListItem -Web $web -List $List -Query "<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>$Name</Value></Eq></Where></Query></View>"
if ($item) {
$setItem = Set-PnPListItem -Web $web -List $List -Identity $item -Values @{"value" = $Value }
Write-Output ("Item updated")
}
else {
$addedItem = Add-PnPListItem -Web $web -List $List -Values @{"Title" = $Name; "value" = $Value }
Write-Output ("Item created")
}
}
# Modify Planner.aspx
$pageTitle = $web.Title + " Planner Board"
$setPlannerPage = Set-PnPClientSidePage -Identity "Planner" -CommentsEnabled:$false -Title $pageTitle -Publish
Write-Output ("Finished Provisioning the site: " + $SPOSiteUrl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment