Finding files in Sharepoint Online or Teams that exceed 218 path length

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

6
Leave a Reply

avatar
5 Comment threads
1 Thread replies
4 Followers
 
Most reacted comment
Hottest comment thread
5 Comment authors
EnriqueDaveTrondMJosSean Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of
trackback

[…] 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 […]

Enrique
Guest
Enrique

It’s great!.
Thank you

Dave
Guest
Dave

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.

TrondM
Guest
TrondM

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

Sean
Guest
Sean

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.