the problem is that -exclude
parameter will fail if get-childitem is launched on the root of drives (same problem on PS V3). More details here : http://powershell.com/cs/forums/p/12202/21382.aspx#21382
here is my poor workaround :
$exclude=@('$RECYCLE.BIN',"SYSTEM VOLUME INFORMATION","Thumbs.db")
ls e: | ?{ $exclude -notcontains $_.name }|%{
ls -recurse -force $_.fullname} |%{
$_.attributes=[System.IO.FileAttributes]::Archive
}
Unfortunatly i cannot use wildcars with this.