这是我在 Windows 10 上的命令:
PS C:\Users\me> Get-ChildItem -Path "\\sharename\path1\engineering" -Recurse > file_data.txt
这是我的输出:
Get-ChildItem : Could not find a part of the path '\\sharename\path1\engineering\Litigation
Images\nsharma\A - Investments documents\Wall Street, finance and related\Education, conferences, and
seminars\Back-office, fund accounting, related\AMF Workshop on Fails Management and Resolution_files'.
At line:1 char:1
+ Get-ChildItem -Path "\\sharename\path1\engineering" -R ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (\\sharename\path1\...esolution_files:String) [Get-ChildItem], DirectoryNotFound
Exception
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
我可以在输出文件 file_data.txt 中看到,导致错误的文件/路径后没有返回任何内容。
我想检索所有可能不出错的文件,稍后再处理错误。目前,搜索在第一个错误处停止。
答案1
是否像添加一样简单
-ErrorAction SilentlyContinue
到行末?我本来想将其添加为注释,但我做不到……