I have to add the local files to list item as an attachment with PowerShell. While reading the file I got an error "Access Denied" as below-
**Exception calling "ReadAllBytes" with "1" argument(s): "Access to the path 'D:\Projects\Test\List Data\Attachments\3' is denied."
$filePath = "D:\Projects\Test\List Data\Attachments\" + $item.ID $bytes = [System.IO.File]::ReadAllBytes($filePath) $item.Attachments.Add([System.IO.Path]::GetFileName($filePath),$bytes) $item.Update()
How to fix this?