I am still learning Powershell and am having problems modifying to script below. I found this at <http://bhatiaashish.blogspot.com/2012/08/powershell-script-to-download.html>. 

This script works but I would like to only grab attachments if item has a category of "red". I have tried adding the piping on line startin $l but must be understanding something wrong. Also the folder this saves the attachments to is named "**System.Object Item(int index) {get;set;}, System.Object Item(string fieldName) {get;set;}, System.Object Item(System.Guid fieldId) {get;set;}**" How could I change script to create the folder with same name as the list?

```
# Add SharePoint Snapin to PowerShell            
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)     {            
Add-PSSnapin Microsoft.SharePoint.PowerShell            
}  

$webUrl = "http://testsite"    
$library = "testlist"   
#Local Folder to dump files
$tempLocation = "c:\TestAttachments"       
$s = new-object Microsoft.SharePoint.SPSite($webUrl)    
$w = $s.OpenWeb()         
$l = $w.Lists[$library] | ?{$_.Item["category"] -eq "red"}

foreach ($listItem in $l.Items)
{
 Write-Host "    Content: " $listItem.Item
  $destinationfolder = $tempLocation + "\" + $listItem.Item          
   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()    
    }

}

```

Thanks!