0

I have a Flow process that saves PDF attachments on an email to a SharePoint folder.

I want to move them from SharePoint to a local folder on a server. I was hoping, I can run as a PowerShell script as task may be. But really can't find anything or if it is possible. I've seen some stuff where you can push from local folder to SharePoint but didn't have any success reverse engineering the script.

Thanks. Gary

3
  • Thanks, the Get-PnpFile process worked. Need to work on something that downloads all. But a lot further ahead now.
    – Gary
    Aug 19, 2020 at 16:11
  • You can use the Get-PNPListItem command to pull all of the files from a list or library. Example: $ListItems = Get-PnPListItem -List $YourLibrary -PageSize 1000 . Then do a for each loop on the $ListItems Aug 20, 2020 at 2:45
  • Hi @Taco_Buffet , thanks. I've been trying that but it seems it's grabbing all files in my library. I just want the ones in a particular folder.
    – Gary
    Aug 20, 2020 at 18:11

2 Answers 2

0

Did you try FolderServerRelativeUrl parameter?

$devConn = Connect-PnPOnline -Url "https://sharepointed.sharepoint.com/sites/siteA/siteB" -Credentials $myLoginInfo -ReturnConnection

$folderName = "/sites/siteA/siteB/Shared Documents/myfolder/anotherfolder"

$folderItems = Get-PnPListItem -List "Shared Documents" -FolderServerRelativeUrl $folderName -Connection $devConn     

You could also use Get-PnPFolderItem.

$devConn = Connect-PnPOnline -Url "https://sharepointed.sharepoint.com/sites/siteA/siteB" -Credentials $myLoginInfo -ReturnConnection   

$folderName = "/Shared Documents/myfolder/anotherfolder"

$folderItems = Get-PnPFolderItem -FolderSiteRelativeUrl $folderName -Connection $devConn

foreach($item in $folderItems)
{
    Write-Host $item.Name
}

Links:
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/get-pnplistitem?view=sharepoint-ps
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/get-pnpfolderitem?view=sharepoint-ps

1
  • 1
    Thanks. That helped.
    – Gary
    Aug 21, 2020 at 15:05
0

You can use PnP PowerShell to get a file from SharePoint location to download and save it. Use Get-PnPFile command as below.

Get-PnPFile -Url _catalogs/themes/15/company.spcolor -Path c:\temp -FileName company.spcolor -AsFile

The -Url parameter should be a site relative URL

for more reference check Microsoft documentation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.