据我所知,NTFSDirect允许我们直接访问MFT来获取有关NTFS卷上的文件和目录的信息。 https://github.com/luisllamasbinaburo/NTFSDirect
c# 代码:
string vol = "c:";
var fileList = new NTFSDirect.Enumerator(vol, new [] {".txt", ".md"});
foreach(string file in fileList)
{
FileInfo f = new FileInfo(file);
if (!f.Exists) { continue; } //every file is enumerated even ones we don't have access to.
是可以做到这一点的 C# 代码。但我还没见过它包裹在powershell中。
我的问题是:如何通过 PowerShell 脚本执行此操作?
谢谢,
本文讨论在 PowerShell 中使用枚举
但是,我在帮助您方面并没有取得多大进展。这是我大概八年来一直试图解决的问题。试图找到一种更快的方法来枚举除 Get-ChildItem 之外的文件系统对象,因此我将遵循此方法,但这不是我本月看到的第一个此类线程。
看看您是否有幸理解微软文档,如果您能正常工作,请分享。
[NTFSDirect].GetEnumNames() | ForEach-Object {
[pscustomobject]@{
Name = $_
Value = [int]([NTFSDirect]::ps1)
}
} # Returns false even though ps1 files are in the current path