Powershell Don';I don’输出中不需要某些零件信息
大家好,我有以下代码,可以搜索文件夹并返回任何包含down值的字符串:Powershell Don';I don’输出中不需要某些零件信息,powershell,powershell-2.0,powershell-3.0,Powershell,Powershell 2.0,Powershell 3.0,大家好,我有以下代码,可以搜索文件夹并返回任何包含down值的字符串: 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 = @(
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
这个
您好,它没有返回期望的结果,但是当我在其他不同的文件上测试它时,代码是好的。它给出了我需要的结果。@sar04x。也许问题出在你测试的文件上!很乐意帮忙。
Get-ChildItem -recurse |
MultiSelect-String 'report','Product1' |
select fullname # or select -expa fullname