gci and -include and -exclude

I am trying get a limited set of files from a directory tree.  The following is what i want but it doesn't work.  I get 
everything.


  get-childitem -LiteralPath \rm5_0_code_h\source -include *.frm,*.ctl,*.bas,*.cls,*.cs,*.cpp,*.hpp,*.sql,*.java -Recurse


I have even tried to exclude what i don't want but it doesn't seem to matter.

get-childitem -LiteralPath $path -include *.frm,*.ctl,*.bas,*.cls,*.cs,*.cpp,*.hpp,*.sql,*.java -recurse -exclude 
*alter*.sql,*.dll,*.pdb,*.ncb,*.tlb,*.scc,*.bmp,*.ico

i still get them all.  what am i doing wrong?

dan
0
Dan
5/14/2010 2:42:26 PM
windows.powershell 690 articles. 0 followers. Follow

1 Replies
1601 Views

Similar Articles

[PageSpeed] 4

you have to ask for all files and then filter with the include. Example:
ls * -include *.exe  #ask for all files in the actual dir and then  apply 
the filter.

You miss the first *


"Dan Holmes" <dan.holmes@routematch.com> wrote in message 
news:#TXQtO38KHA.3840@TK2MSFTNGP02.phx.gbl...
> I am trying get a limited set of files from a directory tree.  The 
> following is what i want but it doesn't work.  I get everything.
>
>
>  get-childitem -LiteralPath \rm5_0_code_h\source -include 
> *.frm,*.ctl,*.bas,*.cls,*.cs,*.cpp,*.hpp,*.sql,*.java -Recurse
>
>
> I have even tried to exclude what i don't want but it doesn't seem to 
> matter.
>
> get-childitem -LiteralPath $path -include 
> *.frm,*.ctl,*.bas,*.cls,*.cs,*.cpp,*.hpp,*.sql,*.java -recurse -exclude 
> *alter*.sql,*.dll,*.pdb,*.ncb,*.tlb,*.scc,*.bmp,*.ico
>
> i still get them all.  what am i doing wrong?
>
> dan 

0
Michael
5/14/2010 11:40:13 PM
Reply:

Similar Artilces:

gc from a txt file, put it in a variable, and pass to gci
I am trying to take a list of servers in a text file and put them into the variable $Server, the pass that variable on to the get-childitem cmdlet to get the ACL information of all of the folders in the "SDATA" folder where inheritance is turned off. $Server = get-content c:\scripts\servers.txt | Foreach-Object {Get-ChildItem \\$Server\SDATA | ? {$_.PSIsContainer} | ? {Get-Acl $_.FullName | % {$_.GetAccessRules($true, $true, 'System.Security.Principal.NTAccount') | ? {!$_.IsInherited}}} | get-acl | export-csv output4.csv -noType} Most of the script works. ...