PowerShell script to identify documents with long path names
I wrote this PowerShell script to identify all documents in a site that exceed 256 characters in length. See http://technet.microsoft.com/en-gb/library/ff919564(v=office.14).aspx for more information.
Feel free to copy the code and use the script as you see fit (at your own risk of course, I can not and will not take responsibility for any undesired outcome).
Param([String] $Site = $(Throw 'Error, no site URL specified.')) <# --------------------------------------------------------------------- PowerShell script to report on all files and folders within a site that exceed 256 characters. For more information, see the link below. File : Get-LongPaths.PS1 Author : David Webb Date : 19/06/2014 Version : 1.0 Revision history: ----------------- 1.0 Initial version Usage: ------ Run Get-LongPaths.PS1 <Site URL> Example: Get-LongPaths.PS1 http://intranet/hr --------------------------------------------------------------------- #> # ----------------------- # Add required snap-in(s) # ----------------------- Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0 # ----------------------- # Define global variables # ----------------------- $Date = Get-Date -Format yyyy-MM-dd_h-mm $Logging = "True" $LogFile = "C:\Get-LongPaths $Date.log" If ($Site.EndsWith("/")) { $Site = $Site.Substring(0,$Site.Length-1) } # ------------------------------------------------------------------ # Function to report on folders that exceed 256 characters in length # ------------------------------------------------------------------ Function Get-LongPaths([String]$Site) { $Web = Get-SPWeb -Identity $Site ForEach ($List in $Web.Lists) { If ($List.BaseType -Eq "DocumentLibrary") { ForEach ($Item in $List.Items) { $FullURL = $Site + "/" + $Item.Url If ($FullURL.length -gt "256") { Write-Host $FullURL "-" $FullURL.Length If ($Logging -eq $True) { $FullURL | Out-File -Append $LogFile } } } } } } Get-LongPaths $Site
![[BlogBookmark]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/blogbookmark.png)
![[Blogsvine]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/blogsvine.png)
![[del.icio.us]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/facebook.png)
![[Furl]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/furl.png)
![[Google]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/google.png)
![[LinkedIn]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/linkedin.png)
![[MySpace]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/myspace.png)
![[Reddit]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/reddit.png)
![[Slashdot]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/slashdot.png)
![[StumbleUpon]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Twitter]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/twitter.png)
![[Windows Live]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://www.adventuresinsharepoint.co.uk/wp-content/plugins/bookmarkify/email.png)
Very nice script, thanks for sharing.