Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$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