2014-03-24 32 views
0
沒有結果

我有以下代碼:傳遞多個字符串,以獲取路徑,但在PowerShell中

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 

當我執行的代碼,它應該給我的路徑+文件(目錄/文件名)的名字

但是它給了我沒有結果,但是當我執行同樣沒有|選擇-unique路徑

它給了我結果,它是無用的我。如何獲取目錄路徑和文件名。任何想法 ?

回答

1

Path不是fileInfo object的屬性。使用directoryfullname代替:

Get-ChildItem -recurse | MultiSelect-String 'v1','Produit','quota'| select -unique directory # for path or fullname for path\filenamt.ext 
+0

Hi CB。它工作正常謝謝 – sar04x

+0

@ sar04x很高興幫助! –

相關問題