如何使用PowerShell获取文件列表和扩展属性
我正在尝试在Powershell做某事,但我正在努力。
我想获取我的计算机中所有文件的列表,该文件具有带有名称的扩展属性(ea):'$ kernel.smartlocker.originclaim'
。
我得到了一些帮助并有基本的代码,但是它不起作用,我认为这是不对的。
ls C:\ -Recurse -ErrorAction SilentlyContinue | Where-Object {
$File = Get-NtFile -Path $_.FullName -Win32Path -Access ReadEa -ErrorAction SilentlyContinue
if ($File) {
$ExtendedAttributes = $File.GetEa()
$ExtendedAttributes.Entries | Where-Object { $_.Name -eq '$Kernel.Smartlocker.OriginClaim' }
}
}
我正在使用一个非标准的powershell模块,我发现在这里 该模块添加了一个提供商和CMDLET,以访问NT对象管理器名称空间。它使我可以使用get-ntfile。
$ _。名称
正在显示文件名而不是属性,至少是我的感觉。 另外,我不知道如何将其发送到可以看到文件名,文件路径和ExtendedAttribute名称的文件。
尽管我正在使用它,但我不需要这样做,但我只想要一些让我找到所需的属性的东西。
有人可以帮忙吗?
提前致谢! Aganju
I am trying to do something in PowerShell but I am struggling with it.
I would like to get a list of all the files in my computer that has an Extended Attribute (EA) with name: '$KERNEL.SMARTLOCKER.ORIGINCLAIM'
.
I got some help and have a basic code, but it doesn't work, I don't think it's doing the right thing.
ls C:\ -Recurse -ErrorAction SilentlyContinue | Where-Object {
$File = Get-NtFile -Path $_.FullName -Win32Path -Access ReadEa -ErrorAction SilentlyContinue
if ($File) {
$ExtendedAttributes = $File.GetEa()
$ExtendedAttributes.Entries | Where-Object { $_.Name -eq '$Kernel.Smartlocker.OriginClaim' }
}
}
I am using a non-standard PowerShell module that I found here
This module adds a provider and cmdlets to access the NT object manager namespace. It allows me to use Get-NtFile.
The $_.Name
is displaying the file name and not the attribute, at least that's the feeling I have.
Also, I don't know how to send this to a file where I could see the filename, the file path and the ExtendedAttribute Name.
Although I am using this, I don't have any requirement to do so, I just want something that allows me to get the attribute I am looking for.
Anyone can help?
Thanks in advance!
Aganju
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我用已知的“ $ kernel.purge.esbcache”测试了以下测试,它肯定有效,这表明Mathias的建议对我来说是正确的。这将为您输出文件
I tested the below with a known entry "$KERNEL.PURGE.ESBCACHE" and it definitely works, suggesting Mathias' suggestion is correct to me. This will output to a file for you