Last active
June 25, 2020 05:30
-
-
Save Vintaurus/6c106c3ecc5077522d5bace0906584a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ScriptFiles{ | |
#get all files | |
$query ="<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq></Where></Query><ViewFields><FieldRef Name='FileLeafRef' /><FieldRef Name='FileDirRef' /></ViewFields></View>" | |
$listItems = Get-PnPListItem -List $librarySiteAssets -Query $query | |
$libraryFolderPath = $librarySiteAssets + $scriptFolder | |
$folderPath = $PSScriptRoot + "\" + $folderFiles | |
foreach($listItem in $listItems){ | |
#get all items in the folder 'Scripts' | |
if($listItem.FieldValues.FileDirRef -match $scriptFolder){ | |
$scriptFile = $libraryFolderPath + "/" + $listItem.FieldValues.FileLeafRef | |
#Save file to locale | |
Get-PnPFile -Url $scriptFile -AsFile -Path $folder | |
#Add file data to provsioning template | |
$filePath = $folderPath + "\" + $listItem.FieldValues.FileLeafRef | |
Add-PnPFileToProvisioningTemplate -Path $provisioningTemplateFilePath -Source $filePath -Folder $libraryFolderPath | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment