Hi @Karl,
You could refer to following script to download file
$LocalFolder = 'C:\Reports'
$UrlSharepoint = 'https://zietza.sharepoint.com'
$UrlSite = '/sites/tm_Finance'
$LibraryFolder = '/Shared Documents/Budgets'
# Connect to Sharepoint and save the connection
$Connection = Connect-PnPOnline -Url "${UrlSharepoint}${UrlSite}" `
-Credential $Credential `
-ReturnConnection `
-ErrorAction Stop
try {
Get-PnPFolderItem -FolderSiteRelativeUrl $LibraryFolder `
-Connection $Connection `
-ItemType File `
-Recursive |
Where-Object {$_.ServerRelativeUrl -like "*" } |
Select-Object name, @{
name='SiteRelativePath'
expr={$_.ServerRelativeUrl.Substring($UrlSite.Length)}
} |
ForEach-Object {
Get-PnPFile -Url $_.SiteRelativePath `
-AsFile `
-Path $LocalFolder `
-Filename $_.name `
-Connection $Connection
}
}
finally {
# Make sure to disconnect
Disconnect-PnpOnline -Connection $Connection
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.