Update: new version of this script with GUI here 🙂
A well known issue when migrating to Office 365 (Sharepoint, Teams and Onedrive) is path length.
Recently, Microsoft increased the maximum path length in Sharepoint Online from 256 to 400 characters (total length of the URL). This causes issues when you use Office, because Office 2013, 2016 and 2019 do not support paths over 218 characters in length.*
To help you proactively identify files that exceed this limit I wrote a PowerShell script you can run:
- it can filter based on file type
- automatically finds and processes all sharepoint sites in your tenant
- automatically finds and processes all team sites in your tenant
- it can handle multi-factor authentication
Find get-filesWithLongPathsInOffice365.ps1 on GitLab
It leans heavily on the great work done by the community around OfficePnP, all credits to the community for providing so much quality code for free!
*longer paths may still work, this is not a hard limit
I will suggest you to try LongPathTool here. It might work here
Can this be amended to just run on one site within a tenant?
Hi,
I would require help/advice on fix-filesWithLongPathsinOffice365.
When I try to run the script, I get 2 errors on 2 different lines.
“Cannot index into a null array.
At C:\Users\name\Documents\fix-filesWithLongPathsInOffice365.ps1:159 char:5”
“Index operation failed; the array index evaluated to null.
At C:\users\name\Documents\fix-filesWithLongPathsInOffice365.ps1:167 char:13”.
Do you have any idea what could be?
Kind regards & have a nice day,
Dino
Hi Jos, thanks a lot for this piece of gold. I got a question though: we’re figuring out how to shorten the paths. One of the ideas was to replace all spaces with an underscore to avoid all the %20 in URL, but then I started comparing the results and I realized we’re counting the path with spaces, in fact. Should we assume that the URL is even longer if we’re using spaces then the one calculated by this script?
THANKS !!
Hi! I’m trying to run the script on large library (5000+ files) and unfortunately, it exceeds threshold. As I’m not the most experienced ps user, it’s quite an obstacle… anyone having some useful hints on that?
[…] find files over a certain path length in Office 365, I wrote a script a while back. This required manual perusal of the results and manual correction […]
It’s great!.
Thank you
This worked for me the first time, but when I run it again, it won’t export the CSV with $exportCSV appended, and gives me an error on each library 403:Forbidden, although it does still spit the results into a table.
Cool script! I’m a powershell newb, is it possible to edit the script so that only the default document libraries are checked? Thus speeding up the time it takes for the script to run, since the other SP lists are bypassed
Great script, thank you. Question: Does the total path length restriction in both Sharepoint and Office refer to the file path + file name length or just the file path? I ask as your script exports the file path character length but doesn’t include the file length…I can easily add it using SUM(LEN(a)+(LEN(b)) but was more curious if you know what the actual restriction is so I can solve for it properly.