2

I am trying to return a list of files based on a filter of cash_st_export*.txt but it doesn't work! If I run gci *.dll on an XP workstation in the default Powershell working directory it works fine.

PS C:\Program Files\iNovah 2 [Test]\WebServices\iNovah2WebService\ExportFiles> 
gci cash_st_export*.txt

PS C:\Program Files\iNovah 2 [Test]\WebServices\iNovah2WebService\ExportFiles> 
gci *.txt

PS C:\Program Files\iNovah 2 [Test]\WebServices\iNovah2WebService\ExportFiles> 
ls


Directory: C:\Program Files\iNovah 2 [Test]\WebServices\iNovah2WebService\ExportFiles


Mode                LastWriteTime     Length Name                                                                                               
----                -------------     ------ ----                                                                                               
d----          4/7/2011   2:23 PM            Archive                                                                                            
-a---         3/24/2011   6:30 PM          0 cash_sei_export_03242011_183015278.txt                                                             
-a---         3/25/2011   6:30 PM        294 cash_sei_export_03252011_183047903.txt                                                             
-a---         3/28/2011   6:30 PM        462 cash_sei_export_03282011_18302584.txt                                                              
-a---         3/29/2011   6:30 PM          0 cash_sei_export_03292011_183040422.txt                                                             
-a---         3/30/2011   9:38 AM        336 cash_sei_export_03302011_093800868.txt                                                             
-a---         3/30/2011   6:30 PM          0 cash_sei_export_03302011_18300400.txt                                                              
-a---         3/31/2011   2:04 PM          0 cash_sei_export_03312011_140407388.txt                                                     
user708516
  • 373
  • 2
  • 4
  • 10

1 Answers1

0

Try this:

gci * -include cash_st_export*.txt

Anyway cash st export seems not exist in the result of ls, but cash sei export.


Similar thread here.

Check also MS doc.


I've tested now gci on my W2K8 server and works fine. You need to use * only if you use include without force.

gci * -include add*.txt

Using this:

gci add*.txt

is actually the same as:

gci -path add*.txt

All this applies to Powershell v2.0 and (I think) to 1.0 also.

NOTE: your workaround in the comment still refers to sei files.

Community
  • 1
  • 1
Emiliano Poggi
  • 24,390
  • 8
  • 55
  • 67
  • the directory listing was huge and there are cash_st_export*.txt files further down. But for clarification I ran: "gci . -include cash_sei_export*.txt" and it returns no results. – user708516 May 02 '11 at 19:08
  • I was able to cobble this together to achieve my result: gci | where-object { $_.Name -match "cash_sei" } I'm going to leave this open to see if anyone can explain why I have to resort to this to make it work. – user708516 May 02 '11 at 19:38
  • I've found that When using the `Include` parameter without the `Recurse` parameter, the path must point to contents, not a container. Try the new edit. – Emiliano Poggi May 02 '11 at 20:05