如何使用长路径名列出具有特定扩展名的文件,而无需在PowerShell中等待数小时

如何使用长路径名列出具有特定扩展名的文件,而无需在PowerShell中等待数小时,powershell,get-childitem,Powershell,Get Childitem,我需要递归列出UNC路径中具有特定扩展名(.PST)的所有文件 我试过这个: Get-ChildItem -Path "\\DFS.LAN\users\*" -Recurse | ?{$_.Name -like "*.pst"} | Select FullName 出现一些错误(路径太长),如何处理 Get-ChildItem : Impossible de trouver une partie du chemin d'accès '\\DFS.LAN\users\User1\Docu

我需要递归列出UNC路径中具有特定扩展名(.PST)的所有文件

我试过这个:

Get-ChildItem -Path "\\DFS.LAN\users\*" -Recurse | ?{$_.Name -like "*.pst"} |
    Select FullName
出现一些错误(路径太长),如何处理

Get-ChildItem : Impossible de trouver une partie du chemin d'accès '\\DFS.LAN\users\User1\Documents\...'. Au caractère Ligne:1 : 1 + Get-ChildItem -Path "\\DFS.LAN\users\*" -Recurse | ?{$_.Name -li ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ReadError: (\\DFS.LAN\users...:String) [Get-ChildItem], DirectoryNotFoundException + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand

范例

Get ChildItem-LiteralPath'\\?\C:\Very long path'-Recurse

对于UNC路径,这略有不同,前缀为\?\UNC\ 而不是\

Get ChildItem-LiteralPath'\\?\UNC\127.0.0.1\c$\Very long path\'-递归

有没有可能提高这个列表的速度

编辑

也许使用
-Filter
参数可以提高此任务的速度

Get-ChildItem -LiteralPath "\\?\UNC\DFS.LAN\users\*" -Filter "*.pst" -Recurse |
    Select FullName

更新后的命令是否满足了您的需要,或者您还有问题吗?我想您已经用最新的编辑完成了。也许有一件小事:您可能需要执行
选择Object-ExpandProperty FullName
以字符串形式检索名称,或者使用
缩短代码(Get ChildItem-LiteralPath“\\?\UNC\DFS.LAN\users\*”-Filter“*.pst”-Recurse)。FullName
Get-ChildItem -LiteralPath "\\?\UNC\DFS.LAN\users\*" -Filter "*.pst" -Recurse |
    Select FullName