Skip to content

Instantly share code, notes, and snippets.

@Vintaurus
Last active June 25, 2020 05:26
Show Gist options
  • Save Vintaurus/3935e22411de33cbb1fffb18df85d55f to your computer and use it in GitHub Desktop.
Save Vintaurus/3935e22411de33cbb1fffb18df85d55f to your computer and use it in GitHub Desktop.
$siteUrl = "https://vinrotlab.io/"
$provisioningTemplateFileName = "startpage.xml"
$pageFileName = "welcome.aspx"
$librarySitePages = "SitePages"
$exportPath = "C:\export"
$provisioningTemplateFilePath = $exportPath + "/" + $provisioningTemplateFileName
function Get-Page($fileName) {
$pageFile = "/" + $librarySitePages + "/" + $fileName
# Temp file
$filePath = $exportPath + "\" + $fileName
# Export files to the folder
$sitePageFolder = $exportPath + "\" + $librarySitePages
If(!(test-path $exportPath)){
New-Item -ItemType Directory -Force -Path $exportPath
}
If(!(test-path $sitePageFolder)){
New-Item -ItemType Directory -Force -Path $sitePageFolder
}
#Save file to locale
Get-PnPFile -Url $pageFile -AsFile -Path $exportPath -Force
#Copy ..avoid the message '...because it is being used by another process'
Copy-Item $filePath -Destination $sitePageFolder
$copyFile = $sitePageFolder + "\" + $fileName
#Add file data to provisioning template
Add-PnPFileToProvisioningTemplate -Path $provisioningTemplateFilePath -Source $copyFile -Folder $librarySitePages
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment