2014-03-24 34 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很高兴帮助! –

相关问题