Powershell: Bug in Get-ChildItem -exclude ?

Unanswered Powershell: Bug in Get-ChildItem -exclude ?

  • Tuesday, December 19, 2006 12:17 AM
     
     
    Anyone have a workaround for the following behaviour in psh?

    Get-ChildItem -path test -recurse -filter *.cs | foreach-object
    -process { $_.FullName }

    C:\scripts\test\AssemblyInfo.cs
    C:\scripts\test\file1.cs
    C:\scripts\test\file2.cs
    C:\scripts\test\Foo.Designer.cs
    C:\scripts\test\sub\file1.cs

    Get-ChildItem -path test -recurse -filter *.cs -exclude "*Designer*",
    "AssemblyInfo.cs" | foreach-object -process { $_.FullName }

    C:\scripts\test\sub  <------------ This is a folder.  Why is it
    included???  How can I exclude it?
    C:\scripts\test\sub\file1.cs
    C:\scripts\test\file1.cs
    C:\scripts\test\file2.cs

    Get-Help Get-ChildItem -detailed
    ...
        -exclude <string[]>
            Omits the specified items. The value of this parameter
    qualifies the Path parameter. Enter a path element or pattern, such as
    "*.txt". Wildcards are permitted.

            This parameter does not work properly in this cmdlet.  <-------
    They weren't joking!

All Replies

  • Friday, August 03, 2012 5:07 PM
     
     

    You can add | ? {$_.psIscontainer -eq "false"}