I need to list recursively all files in a UNC path with a specific extension (.PST).
I have tried this:
Get-ChildItem -Path "\\DFS.LAN\users\*" -Recurse | ?{$_.Name -like "*.pst"} |
Select FullName
Some errors appears (path too long), how can I deal with it?
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
EDIT
After a little search, it is possible (with PowerShell 5.1) to avoid error with long path name like this:
Get-ChildItem -LiteralPath "\\?\UNC\DFS.LAN\users\*" -Recurse |
?{$_.Name -like "*.pst"} |
Select FullName
Example
Get-ChildItem -LiteralPath '\\?\C:\Very long path' -Recurse
For UNC path, this is slightly different, the prefix being \?\UNC\ instead of \
Get-ChildItem -LiteralPath '\\?\UNC\127.0.0.1\c$\Very long path\' -Recurse
Is it possible to inscrease the speed of this listing?
EDIT
Maybe using the -Filter
parameter increase the speed of this task ...
Get-ChildItem -LiteralPath "\\?\UNC\DFS.LAN\users\*" -Filter "*.pst" -Recurse |
Select FullName