Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 排除基于关键字的任何发现_Powershell_Ntfs - Fatal编程技术网

Powershell 排除基于关键字的任何发现

Powershell 排除基于关键字的任何发现,powershell,ntfs,Powershell,Ntfs,从中找到一行有用的代码 我已经有一段时间没有与PowerShell联系了,所以我试图找出如何包含-Exclude函数来缩小它提供给我的输出范围。对象中有一个名为“Stream”的元素,当它找到字符串“Zone.Identifier”时,我希望排除该对象(整个对象,而不仅仅是那一行)。下面是一个输出示例 我尝试了以下方法,但没有成功 gci -Recurse | % { gi $_.FullName -Stream * -Exclude "Zone.Identifier" } | where s

从中找到一行有用的代码

我已经有一段时间没有与PowerShell联系了,所以我试图找出如何包含
-Exclude
函数来缩小它提供给我的输出范围。对象中有一个名为“Stream”的元素,当它找到字符串“Zone.Identifier”时,我希望排除该对象(整个对象,而不仅仅是那一行)。下面是一个输出示例

我尝试了以下方法,但没有成功

gci -Recurse | % { gi $_.FullName -Stream * -Exclude "Zone.Identifier" } | where stream -ne ':$Data'

-notin
运算符与
where
一起使用:

gci -recurse | % { gi $_.FullName -stream *  } | where stream -notin ':$Data','Zone.Identifier'
您还可以完全跳过
%
(每个对象的别名
ForEach
),并通过管道将项目直接传送到
获取项目

Get-ChildItem -Recurse |Get-Item -Stream * |Where-Object Stream -notin ':$Data','Zone.Identifier'
(扩展别名以提高可读性)

Get-ChildItem -Recurse |Get-Item -Stream * |Where-Object Stream -notin ':$Data','Zone.Identifier'