Powershell ReadError Truncated path

I have been running the following command:

Get-ChildItem "D:\UserShares\create" -recurse | Measure-Object -property length -sum | ft -autosize | out-string -width 4096

Error:

Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 26
0 characters, and the directory name must be less than 248 characters.
At line:1 char:14
+ Get-ChildItem <<<<  "D:\UserShares\create" -recurse | Measure-Object -property length -sum | ft -autosize | out-strin
g -width 4096
    + CategoryInfo          : ReadError: (D:\UserShares\c...its Logo - Copy:String) [Get-ChildItem], PathTooLongExcept
   ion
    + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand

The issue I have, I cannot view the full path for file: ReadError: (D:\UserShares\c...its Logo - Copy

As it has been truncated, any help to view the full path.

Regards,

introlux
introluxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joshua GrantomSenior Systems AdministratorCommented:
Getting the full path is difficult but you could at least get the folder path by collecting all of the errors and displaying at the end.

Get-ChildItem C:\temp\ -recurse -ErrorAction SilentlyContinue -ErrorVariable err | Measure-Object -property length -sum | Select Count,Sum | ft -autosize | out-string -width 4096

foreach ($errorRecord in $err)
{
    if ($errorRecord.Exception -is [System.IO.PathTooLongException])
    {
        Write-Warning "Path too long in directory '$($errorRecord.TargetObject)'."
    }
    else
    {
        Write-Error -ErrorRecord $errorRecord
    }
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
introluxAuthor Commented:
Thanks!
Joshua GrantomSenior Systems AdministratorCommented:
you're welcome!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.