SharePoint 2016/2013/Online: How download SharePoint List Item Attachments by PowerShell Automation

Downloading List Item Attachments is normally required when we are dealing with migration scenarios and sometimes for Custom Backups.

In this article we will explore the PowerShell to download the List Item attachments.

In order to setup this demo I have created a list and added 1 List Item with some of the attachments as shown below:

1

Also I have one folder in the local machine as shown below:

2

In the upcoming section we will do the Step by Step Code Analysis to get better understanding on the core functionality.

Step 1: In this step we will initialize the SharePoint Client Context by passing required credentials

3

Step 2: In this step we will initialize the SharePoint List Object by referencing it using current Client Context and setting up the disk location where the attachments will get downloaded

Step 3: In this step will first check the status of any pending request in the queue, and if there is any pending query then first execute it

Step 4: In this Step we will read the file from SharePoint List Item Attachments collection & save it to the disk location as specified in Step 2

4

Step 5: In this step finally will be call the “DownloadListItemAttachments” Function that will execute the logic we have seen in above steps

5

Once you execute the PowerShell it will ask you for the credentials as per the SharePoint Hosting Environment (On Premise or Online).

Provide the required credentials

6

If the PowerShell scripts executes successfully it will download all the attachment in the disk location as shown below:

7

8

During the real production scenarios it is always advisable to keep all attachments of a specific item in a separate folder govern by a proper naming convention to support smooth tracking of the content later on.

That is all for this demo.

Hope you find it helpful.

8 thoughts on “SharePoint 2016/2013/Online: How download SharePoint List Item Attachments by PowerShell Automation

    • Thanks David. Glad you find it helpful.

      Though this article has not been exposed any code sample and it is just a guidance on how to do it. I hope you can take help from the article to get it implemented your way. In case still you are not able to make it, please drop me an email and will share code with you.

    • Raja, though this article has not been exposed any code sample and it is just a guidance on how to do it. I hope you can take help from the article to get it implemented your way. In case still you are not able to make it, please drop me an email and will share code with you.

Leave a reply to Raja Cancel reply