不希望输出中有一些零件信息

时间:2014-03-21 11:17:41

标签: powershell powershell-v2.0 powershell-v3.0

嗨大家我有以下代码搜索文件夹并返回包含该值的任何字符串:

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 'report','Product1'

因此,如果代码获取文件,则显示如下:

Directory: C:\Users\sarvesh.nundram\Desktop\PMI\RPD_Extract_XML\SQL_tobemigrated2\GROUP1

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        11/21/2013   1:07 PM     133279 Acapulco

如果我不想要这些信息该怎么办:

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        11/21/2013   1:07 PM 

1 个答案:

答案 0 :(得分:0)

此?

Get-ChildItem -recurse | 
        MultiSelect-String 'report','Product1' | 
           select fullname # or select -expa fullname