Max Path Length in Sharepoint Online, Onedrive for Business and Teams

Many Office 365 clients (and especially Excel) really don’t like long paths. The older the client, the worse the issues.

To 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 of the issues.

The new version of my script now features fully automatic discovery, a flexible editor and automatic correction of paths based on what you entered into the editor.

Correcting path lengths in Sharepoint Online, Onedrive for Business and Microsoft Teams

You can get the PowerShell script / editor from my git repository here.

Many thanks to CTS in their help me designing and testing this script!

How to use

  1. download the script and save it somewhere
  2. Copy the desired Sharepoint Library into a new Sharepoint Library and/or site
  3. Run the script only for that site or library by specifying the -specificSiteUrls or specificDocumentLibraries parameter
  4. do some corrections, commit them, check the results
  5. If satisfied, set permissions for your admin account on the actual production locations your wish to fix (script for Onedrive Mass Permissions here)
  6. Ensure no users have open files in the library
  7. Remove any non-standard characters from folder names (see script source, example code at the top)
  8. Run

Disclaimer

  • Please make sure you TEST this on a copy of your document library/sites before using the ‘commit’ option.
  • Use at your own risk.
  • I recommend turning on the Universal Audit log before usage.

Subscribe
Notify of
guest

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

19 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Daniel
Daniel
9 months ago

Is it possible to use this to scan subsites? I have a subsite that does not include the /site/ portion. AKA https://Contoso.sharepoint.com/sites/testsite would be the general and the subsite is https://Constoso.sharepoint.com/subsite and is not being picked up in the scan but the other 50 sites in our collection are

Sérgio Fangueiro
Sérgio Fangueiro
4 months ago

When finish gives me GUi with null examples, and with this error: Index operation failed; the array index evaluated to null

Sérgio Fangueiro
Sérgio Fangueiro
4 months ago

Hi Jos.

After my credentials windows open i type it always say some error:

Could not connect to SpO online, check your credentials
At C:\Users\se19138\Downloads\fix-filesWithLongPathsInOffice365.ps1:251 char:9
+ Throw “Could not connect to SpO online, check your credential …

Lars
Lars
7 months ago

Could you be a bit more specific towards this “.PARAMETER specificSiteUrls
“Comma seperated list of sites to process. If not specified ALL sites are processed (including Onedrive for Business and Microsoft Teams)”

I have tried different variations be is does not work, tried this
-specificSiteUrls ,MARKETING,
specificSiteUrls https://intenzaarhus.sharepoint.com/sites/MARKETING

Nothing works here, so it would be great if you included an example just like specificDocumentLibraryUrls

trackback

[…] max path length tool has been […]

Andres
Andres
9 months ago

hello!
Thank you for this script. I was wondering if there is a way to only target the script for the specified URLs. I have added my specific site URLS but once the script starts and it recognizes them, the script continues to run discovery and then picks up my user’s personal OneDrive subsites. This then causes the script to get overwhelmed later on. Is this supposed to be happening?

Thank you in advanced.

trackback

[…] Max Path Length in Sharepoint Online, Onedrive for Business and Teams […]

trackback

[…] Max Path Length in Sharepoint Online, Onedrive for Business and Teams | Liebensraum […]