Archive for July, 2010

Locating files and pages with URLs that are too long for SharePoint

As you may already know, SharePoint has a limitation on how long a page or file path (or URL) can be.  This was an issue with SharePoint 2007 -Joel Oleson blogged about it back in June 2007:

“When storing files the structure and files (entire path including sites, folders, and file name) cannot add up to more than 260 characters or they will see an error message or form validation error with the explanation around the URL length. “ 

Official Microsoft documentation states that the same limit holds for SharePoint 2010:

“SPSite.MaxFullUrlLength Field

Represents the maximum number of characters that can be used in the absolute URL for a site collection.


The value of this constant is 260.

The MaxFullUrlLength field is static and cannot be called on an instance object. To call this field, use SPSite.MaxFullUrlLength.”


When you’re moving, upgrading, or migrating SharePoint sites, you may run into problems with URLs that are too long for SharePoint.  You may see failures or errors when executing STSADM commands such as “stsadm -o export” or “stsadm -o import”.

I wrote a PowerShell script (see below) that allows you to take an inventory of all files in your web application and flag those files where the path (or URL) is longer than 260 characters.

You can call this script from a command line as follows:

powershell   C:\Inventory.ps1  "http://sharepointURL" >   C:\output.txt


Source code

 # This script enumerates all files at the specified URL,
 # and outputs full URL for each file,
 # along with the length of the URL.

# define EnumPages function

function EnumPages
param ($URL, $objFolder)

 # enumerate files in the root folder

 foreach ($file in $objFolder.Files)

 $result = "OK"
 $output = $URL + "/" + $objFolder.URL + "/" + $file.Name

# evaluate string length
 if ($output.length -ge 260) { $result = "TOO LONG" }

# write output

 write-host $output, ";" , $output.length, ";" $result, ";"
 # enumerate subfolders

 foreach ($subfolder in $objFolder.SubFolders)

 EnumPages $URL $subfolder


 # begin script body
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null

 $siteURL = $args[0]

# create a new SPSite object

$site=new-object Microsoft.SharePoint.SPSite($siteURL)

 # enumerate files in the Rootweb

 foreach ($file in $site.Rootweb.Files)

$result = "OK"

 $output = $site.Rootweb.URL + "/" + $file.Name 

 if ($output.length -ge 260) { $result = "TOO LONG" }

  write-host $output, ";", $output.length, ";" , $result


 # enumerate folders in the Rootweb

 foreach ($folder in $site.Rootweb.Folders)

 EnumPages $site.Rootweb.URL $folder


 # enumerate subsites

 foreach ($web in $site.Allwebs)

  # enumerate files in the root web

  foreach ($file in $web.Files)

$result = "OK"

$output = $web.URL + "/" + $file.Name 

 if ($output.length -ge 260) { $result = "TOO LONG" }

 write-host $output, ";", $output.length, ";" , $result


  # enumerate folders

  foreach ($folder in $web.Folders)

  EnumPages $web.URL $folder



$site.Dispose(); ##ENFORCED DISPOSAL!!!    



Installing SharePoint 2010 on Windows Server 2008 R2 – which server roles and features do I need?

If you’re installing SharePoint Server 2010, you will need to address the hardware and software prerequisites for SharePoint 2010.    This time around, Microsoft put together a nice TechNet page that tells you the basics of what you need before you install SP 2010:

This is a fairly comprehensive page, but there are some gaps in this document.  For instance, it tells you that you need to configure your server with the following roles:

  • Web Server (IIS) role
  • Application Server role
  • However, each of these roles consists of a number of role services – how do you know which role services need to be turned on for SharePoint 2010?   And if you miss one of the role services, you’ll get the following error when trying to install SharePoint 2010:

    “Setup is unable to proceed due to the following error(s):

    Windows Server Features or role services required by this product are not enabled. ”

    Below I’ve posted screenshots from one of my virtual machines where I was able to successfully install SharePoint Server 2010.  If you’re getting the error shown above, compare these screenshots to your configuration to find out which role services you’re missing.

    1. Turn on Application Server Role and make sure these role services are also turned on:

    2. Turn on Web Server Role and make sure that these role services are also turned on:

    3. On my VM, I also have the File Services role turned on:

    4. Go to Server Manager > Features and make sure that you have the following Features turned on:

    Good luck with your SP 2010 install!

    RSS Information Week Headlines

    • An error has occurred; the feed is probably down. Try again later.

    RSS SharePoint Team Blog

    • An error has occurred; the feed is probably down. Try again later.

    RSS InfoPath Team Blog

    • An error has occurred; the feed is probably down. Try again later.

    RSS Joel Oleson Blog

    • An error has occurred; the feed is probably down. Try again later.

    RSS Susan Hanley’s KM Blog

    • An error has occurred; the feed is probably down. Try again later.

    Blog Stats

    • 372,518 hits