 $webUrl = "https://bcdtravelke.sharepoint.com/finance"    
 $library = "New AP Account"   
 #Local Folder to dump files
 $tempLocation = "Z:\Staff-Files\Ronney\spattachments"     
 $s = new-object Microsoft.SharePoint.SPSite($webUrl)    
 $w = $s.OpenWeb()         
 $l = $w.Lists[$library]    
 foreach ($listItem in $l.Items)
 {
     Write-Host "    Content: " $listItem.ID 
     $destinationfolder = $tempLocation + "\" + $listItem.ID          
       if (!(Test-Path -path $destinationfolder))        
         {            
         $dest = New-Item $destinationfolder -type directory          
         }
     foreach ($attachment in $listItem.Attachments)    
          {        
              $file = $w.GetFile($listItem.Attachments.UrlPrefix + $attachment)        
              $bytes = $file.OpenBinary()                
              $path = $destinationfolder + "
\" + $attachment 
              Write "
Saving $path" 
               $fs = new-object System.IO.FileStream($path, "
OpenOrCreate") 
               $fs.Write($bytes, 0 , $bytes.Length)    
               $fs.Close()    
           }
   }