I have this on-premises power shell script which reads SharePoint list attachments and save them to local folder:
$ItemAttachmentURLPrefix =$HeaderListItem.Attachments.UrlPrefix
$attachmentCollection = $HeaderListItem.Attachments
$AttachmentSeq = 0
ForEach($Attachment in $attachmentCollection)
{
Write-Host "`tDownloading Attachement: " $attachment $ItemAttachmentURLPrefix
$AttachmentSeq++
$AttachmentDataObj = "" | Select "Attachment Seq", "JDE Company", "Vendor Number", "Vendor Invoice Number", "Attachment Name", "Attachment System Name", "Job-run Date/Time Stamp"
$file = $spSourceWeb.GetFile($ItemAttachmentURLPrefix + $attachment)
$bytes = $file.OpenBinary()
$AttachmentFileName = $FilePrefix + "_AP_" + $InvoiceIDFormatted + "_" + $attachment
$Attachmentpath = $AttachmentFolder + $AttachmentFileName #$FilePrefix + "_*emphasized text*AP_" + $InvoiceIDFormatted + "_" + $attachment
$fs = new-object System.IO.FileStream($Attachmentpath, "OpenOrCreate")
$fs.Write($bytes, 0 , $bytes.Length)
$fs.Close()
}
But how can I convert this to PnP PowerShell?