In this blog post, we’ll walk through how to easily download file attachments from a SharePoint list using PnP PowerShell. SharePoint lists allow users to attach files to items, and sometimes you may need to automate the process of downloading those attachments. Thankfully, with the power of the PnP PowerShell module, this task becomes incredibly straightforward.
1. Install the PnP Module
The first step is to install the PnP.PowerShell module. Use the following command:
Install-Module -Name PnP.PowerShell -Force
2. Authenticate with SharePoint
Authenticate to your SharePoint environment. Here, certificate-based authentication is used and the application is configured with All Sites Full Control.

Use the command:
Connect-PnPOnline -Url $siteURL -Thumbprint $ThumbPrint -ClientId $SPOClientID -Tenant $TenantName
$TenantName: Your tenant’s name
$siteURL: The URL of the site collection.
$ThumbPrint: The thumbprint of the certificate used for authentication with the Azure AD application.
$SPOClientID: The client ID of your Azure AD application.
Note: There’s no need to explicitly import the module, as PowerShell automatically imports it when you invoke a command from an installed module.
3. Download List Item Attachments
To download file attachments from a SharePoint list item, use the following command:
Get-PnPListItemAttachment -List $lst -Identity $ID -Path $folderpath -verbose -Force
$lst: The name of the SharePoint list.
$ID: The ID of the list item containing the attachment.
$folderpath: The destination path where the attachment will be saved.
4. Disconnect from PnP Online
After completing the required operations, disconnect the session using:
Disconnect-PnPOnline
The above steps are designed for PowerShell 7. They will not work with PowerShell 5 due to compatibility issues with the PnP.PowerShell module. Ensure that your Azure AD application is configured correctly with the necessary permissions.
Thanks for reading…
Tech Wizard
https://techwizard.cloud