Add-SSPFiles.ps1
<# .Synopsis Uploades the files in a folder in the site/tennant. .Description This CmdLet uploads all the files that match the matches in a particular folder. .Parameter Files This parameter contains the Files or File Names to upload from the specified path. .Parameter Path This parameter contains path from which to upload the files. .Parameter Folder This parameter contains the name/path of the folder in which to upload the files. .Parameter Connection This parameter provides the context for the call. The default is the current connection returned by "Get-PnPConnection". .Example PS> Add-SSPFile -Path "." -Files ("image1.png", "image2.jpg") -Folder "Site Assets" .Example PS> $files = Get-SSPFile -Path "." -Folder "Images" -Matches "*.jpg" PS> Add-SSPFile -Path "." -Files $files -Folder "Site Assets" #> function Add-SSPFiles { param( $files, [string] $path, [string] $folder, $connection = (Get-PnPConnection) ) ForEach ($file in $files) { if ($file.GetType().Name -eq "File") { $f = $file.Name } else { $f = $file } Write-Host "Uploading ""$path/$f"" to ""$folder""" Add-PnPFile -Path "$path/$f" -Folder "$folder" -Connection $connection Write-Host "Done Uploading ""$path/$f"" to ""$folder""" } } |