Ignore errors on recursive search
By David Jones •
This is my command on Windows 10:
PS C:\Users\me> Get-ChildItem -Path "\\sharename\path1\engineering" -Recurse > file_data.txtAnd this is my output:
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.GetChildItemCommandI can see in the output file file_data.txt that nothing was returned after the file/path that caused the error.
I want to retrieve all the possible files that won't error, I'll deal with the errors later. As it stands now, the searching stops at the first error.
1 Answer
Is it as simple as adding
-ErrorAction SilentlyContinueto the end of your line? I would have added this as a comment but I can't...