Вопрос

I have the following codes:

filter MultiSelect-String( [string[]]$Patterns ) {

    # Check the current item against all patterns.
    foreach($Pattern in $Patterns) {

        # If one of the patterns does not match, skip the item.
        $matched = @($_ | Select-String -Pattern $Pattern)

        if(-not $matched) {
            return
        }
    }

    # If all patterns matched, pass the item through.
    $_
}

Get-ChildItem -recurse | MultiSelect-String 'v1','Produit','quota'| select -unique path

when i execute the code it should give me the path + the name of the file (directory/filename)

However it gives me no results, but when I executed the same without |select -unique path

it gives me results for which it is useless for me. How to get the directory path and the file name. Any idea ?

Это было полезно?

Решение

Path is not a properties for fileInfo object. Use directory or fullname instead:

Get-ChildItem -recurse | MultiSelect-String 'v1','Produit','quota'| select -unique directory # for path or fullname for path\filenamt.ext
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top