Convert a Sub-site to a Site Collection

Posted on Posted in SharePoint 2007, STSADM Commands

I finally figured it out! This was supposed to be one of those very simple tasks that I should have been able to do without any custom code. Turning a sub-site (or web) into a site collection (or top level site) turned out to be the most difficult task I’ve yet to face with SharePoint 2007. In theory you should be able to do this using the following commands which could be put into a batch file:

REM Create a test web for exporting
stsadm -o createweb -url "http://intranet/testweb" -sitetemplate "SPSTOPIC#0"

REM Export the test web to the filesystem
stsadm -o export -url "http://intranet/testweb" -filename "c:\testweb" -includeusersecurity -versions 4 -nofilecompression -quiet

REM Create a managed path for the new top level site
stsadm -o addpath -url "http://intranet/testsite" -type explicitinclusion

REM Create an empty site with a default site template (note that if you don't specify a template you have to manually activate the required features)
stsadm -o createsite -url "http://intranet/testsite" -owneremail "" -ownerlogin "domain\username" -sitetemplate "SPSTOPIC#0"

REM Import the site
stsadm -o import -url "http://intranet/testsite" -filename "c:\testweb" -includeusersecurity -nofilecompression -quiet

Unfortunately what you get is only a partially functional site (and in some case not functional at all). There are several errors that you are likely to encounter after running the above using the created testweb or your own existing web. The first and most obvious error is that when you load the default.aspx page of the new site you may get a File Not Found error (note that running the above as is will not give you this error). This is the result of the publishing pages PageLayout URL getting messed up (effectively still pointing to an old value). I addressed this specific issue with a separate command ( and the I’ve encapsulated that functionality into the new commands I’ve created which are detailed below.

The next error you’re likely to see is on the Area Template Settings page (Site Settings -> Page layouts and site templates). The specific error is "Data at the root level is invalid. Line 1, position 1".

Anyone who’s done a lot of XML work should recognize this error as an XML parsing error. This error occurs if the web you imported from was set to inherit it’s page layouts from it’s parent. When a web is setup this way there’s a property called "__PageLayouts" which gets set to "__inherit".

For a top level site collection this value should always be either an empty string (all page layouts are available) or XML describing which layouts are available. The import operation does not consider this and leaves the value as is thus resulting in the XML error when attempting to parse "__inherit" as XML. The fix for this is simple enough – change the value to an empty string. Unfortunately that’s not all we have to do. Fixing the above error results in the page loading without errors, however, the page layouts section does not load. There’s still several issues that need to be resolved. If you now go and view the master gallery (Site Settings -> Master pages and page layouts) you should see all the default page layouts. If you have any custom page layouts those won’t exist and will cause problems.

Also, if you attempt to edit a file you’ll notice that even though we used a publishing template it doesn’t prompt you to check the file out. What’s more is that once you view the form for a layout you should see that only the core fields are present (no Content Type, Associated Content Type, Variations, etc.).

There are several things that need to be fixed here – first we need to activate all the features that would otherwise be activated on a new site collection (need this so that we can get the publishing workflow options enabled). Second we need to reset all the properties for the gallery to match that of our source gallery (namely we need to allow management of content types).

Third we have to change the ContentType field from being a Text field to being a Choice field (more about this in a minute). Fourth we need to re-associate each file as a Page Layout file by setting all the necessary properties (Content Type, Associated Content Type, etc.). In regards to changing the ContentType field this is the one that caused me the most headache to figure out. For some reason during the import of the site this field gets a bit messed up (note that I’m not referring to the ContentType field that is linked in from the Page content type which is associated with the library but rather another field that is part of the gallery definition itself). The field should be a Choice field with options such as "Page Layout", "Publishing Mater Page", "Master Page", and "Folder". However, during the import the field is converted to a Text field – don’t ask me why.

The result is that when you query for the list of available page layouts the unmanaged code that Microsoft uses to do the actual query chokes because it can’t find a matching value in the list so it produces an invalid query which will always return no results back. To fix this I copy the source master page gallery on top of the target gallery using the content deployment API. I also found that (with SP2) the PublishingResources feature seemed to correct the issue (at least in the tests that I ran).

UPDATE 9/4/2007: I just discovered that another issue is related to the global navigation. If you view the navigation via the browser it will look as though everything is just peachy but if you attempt to manipulate the navigation programmatically you’ll find that the PublishingWeb’s GlobalNavigationNodes property is empty (no items are present). This is because the global navigation is stored at the site collection level so when you import the web it does not take the global navigation with it, just the current. The fix is simple enough – just loop through the current navigation collection and copy it to the global navigation collection. This will help to allow other programmatic manipulations of the global navigation to succeed.

UPDATE 7/6/2009:  I am now calling the code that I created to copy content types from one site collection to another.  This solves issues that can occur if a site collection content type was not created via a Feature.  I’ve also added additional logging to better show what is happening.

So, to summarize the things that need to be repaired after importing into your empty site collection:

  1. Activate any features that are needed by the site
  2. Set the master page gallery settings
    1. Enable content type management
    2. Set your publishing options
    3. Fix the Content Type field so that it’s a Choice field type by copying the source master page gallery
  3. Copy missing content types from the source site collection.
  4. Fix the Page Layouts and Site Templates
    1. Set the "__PageLayouts" property to an empty string (can then be set to something else using SetAvailablePageLayouts() but first needs to be set to an empty string as SetAvailablePageLayouts() will not work until it’s fixed)
    2. Copy any missing page layouts from the source
    3. Set all appropriate properties on each page layout
  5. Fix all the publishing pages PageLayout property to have the correct URL
  6. UPDATE 9/4/2007: Update the global navigation

Some of the above can be done via the browser but most of it requires programmatic changes. In order to solve all these problems I’ve created two custom stsadm commands – the first will take a site make all the repairs identified above (so it assumes you’ve already imported the site).

The second basically just abstracts the whole process of exporting a web, creating a site, importing into the site, and then repairing the site (this way the entire process can be done with just one command). The commands I created are detailed below (forgive the verbosity of the names – I had trouble coming up with something shorter).

1. gl-repairsitecollectionimportedfromsubsite

The code is fairly well documented so rather than discuss it all (there’s a lot of it) I’ve linked it to this post here. The syntax of the command can be seen below:

C:\>stsadm -help gl-repairsitecollectionimportedfromsubsite

stsadm -o gl-repairsitecollectionimportedfromsubsite

Repairs a site collection that has been imported from an exported sub-site.  Note that the sourceurl can be the actual source site or any site collection that can be used as a model for the target.

        -sourceurl <source location of the existing sub-site or model site collection>
        -targeturl <target location for the new site collection>

The following table summarizes the command and its various parameters:

Command Name Availability Build Date
gl-repairsitecollectionimportedfromsubsite WSS 3, MOSS 2007 Released: 9/4/2007

Updated: 7/6/2009
Parameter Name Short Form Required Description Example Usage
sourceurl source Yes The URL to the source sub-site to convert. -sourceurl http://portal/subsite

-source http://portal/subsite

targeturl target Yes The URL of the new site collection to create. -targeturl http://portal/sites/site

-target http://portal/sites/site

Here’s an example of how to repair the site created using the batch file above:

stsadm –o gl-repairsitecollectionimportedfromsubsite –sourceurl "http://intranet/testweb/" -targeturl "http://intranet/testsite/"

2. gl-convertsubsitetositecollection

As stated above, this command is just an abstraction of other commands – it simply calls out to stsadm to do export the site (note that you can provide a previously exported site file/folder), create the managed path, create the empty site, import the site, and finally repair the imported site. As there’s nothing spectacular going on here I didn’t bother culling the code out in this post (download the project if you’re interested in the details). The syntax of the command can be seen below:

C:\>stsadm -help gl-convertsubsitetositecollection

stsadm -o gl-convertsubsitetositecollection

Converts a sub-site to a top level site collection via a managed path.


        -sourceurl <source location of the existing sub-site or model site collection>
        -targeturl <target location for the new site collection>
        -owneremail <>
        [-suppressafterevents (disable the firing of "After" events when creating or modifying list items)]
        [-exportedfile <filename of exported site if previously exported>]
        [-ownerlogin <DOMAIN\name>]
        [-ownername <display name>]
        [-secondaryemail <>]
        [-secondarylogin <DOMAIN\name>]
        [-secondaryname <display name>]
        [-lcid <language>]
        [-title <site title>]
        [-description <site description>]
        [-hostheaderwebapplicationurl <web application url>]
        [-quota <quota template>]
        [-databaseuser <database username>]
        [-databasepassword <database password>]
        [-databaseserver <database server name>]
        [-databasename <database name>]

The following table summarizes the command and its various parameters:

Command Name Availability Build Date
gl-convertsubsitetositecollection WSS 3, MOSS 2007 Released: 9/4/2007

Updated: 7/6/2009
Parameter Name Short Form Required Description Example Usage
sourceurl source Yes The URL to the source sub-site to convert. -sourceurl http://portal/subsite

-source http://portal/subsite

targeturl target Yes The URL of the new site collection to create. -targeturl http://portal/sites/site

-target http://portal/sites/site

owneremail oe Yes

The site owner’s e-mail address.  Must be valid e-mail address, in the form



createmanagedpath createpath No Create a new managed path for the site collection. -createmanagedpath


haltonwarning warning No Stop execution of the command if a warning event occurs during the export or import process. -haltonwarning


haltonfatalerror error No Stop execution of the command if a fatal error occurs during the export or import process. -haltonfatalerror


exportedfile file No Use a previously exported site (created using stsadm’s export command). -exportedfile c:\exportdata\site

-file c:\exportdata\site

nofilecompression   No Do not compress the site when exporting (or if previously exported use an uncompressed file for the import). -nofilecompression
ownerlogin ol

If your farm does not have Active Directory account creation mode enabled, then this parameter is required.

This parameter should not be provided if your farm has Active Directory account creation mode enabled, as Microsoft Office SharePoint Server 2007 will automatically create a site collection owner account in Active Directory based on the owner e-mail address.

The site owner’s user account.  Must be a valid Windows user name, and must be qualified with a domain name, for example, domain\name

-ownerlogin domain\name

-ol domain\name

ownername on No

The site owner’s display name.

-ownername "Gary Lapointe"

-on "Gary Lapointe"

secondaryemail se No

The secondary site owner’s e-mail address.  Must be valid e-mail address, in the form



secondarylogin sl

If your farm does not have Active Directory account creation mode enabled, then this parameter is required.

This parameter should not be provided if your farm has Active Directory account creation mode enabled, as Microsoft Office SharePoint Server 2007 will automatically create a site collection owner account in Active Directory based on the owner e-mail address.

The secondary site owner’s user account.  Must be a valid Windows user name, and must be qualified with a domain name, for example, domain\name

-secondarylogin domain\name

-sl domain\login

secondaryname sn No

The secondary site owner’s display name.

-secondaryname "Pam Lapointe"

-sn "Pam Lapointe"

lcid   No

A valid locale ID, such as "1033" for English.  You must specify this parameter when using a non-English template.

-lcid 1033
title t No

The title of the new site collection (this value will be overwritten when the site is imported – it is available only to help in situations in which the import fails).

-title "New Site"
description desc No

Description of the site collection (this value will be overwritten when the site is imported – it is available only to help in situations in which the import fails).

-description "New Site Description"

-desc "New Site Description"

hostheaderwebapplicationurl hhurl No

A valid URL assigned to the Web application by using Alternate Access Mapping (AAM), such as "http://server_name".

When the hostheaderwebapplicationurl parameter is present, the value of the url parameter is the URL of the host-named site collection and value of the hostheaderwebapplicationurl parameter is the URL of the Web application that will hold the host-named site collection.

-hostheaderwebapplicationurl http://newsite

-hhurl http://newsite

quota   No

The quota template to apply to sites created on the virtual server.

-quota Portal
deletesource   No Delete the source site after conversion (only recommended if significant testing has occurred). -deletesource
createsiteinnewdb newdb No Create the site collection in a content database. -createsiteinnewdb


createsiteindb db No Create the site collection in an existing content database. -createsiteindb


databaseserver ds No The database server containing the specified content database.  If not specified then the default database server is used. -databaseserver spsql1

-ds spsql1

databaseuser du No

The administrator user name for the SQL Server database.

-databaseuser domain\user

-du domain\user

databasepassword dp No

The password that corresponds to the administrator user name for the SQL Server database.

-databasepassword password

-dp password

databasename dn Yes if createsiteinnewdb or createsiteindb is specified.

The name of the content database to put the site collection in (will be created if createsiteinnewdb is specified).

-databasename SharePoint_Content1

-db SharePoint_Content1

suppressafterevents sae No Disable the firing of After events when creating or modifying files or list items during the import. -suppressafterevents


verbose v No Displays logging information when executing. -verbose


Here’s an example of how to do all that the batch file above is doing (minus the creation of the testweb) as well as the repair operation all with one command:

stsadm –o gl-convertsubsitetositecollection –sourceurl "http://intranet/testweb/" -targeturl "http://intranet/testsite/" -createmanagedpath -nofilecompression -owneremail "" -ownerlogin "domain\user" -deletesource

One area of improvement may be to pull the owner and secondary owner information from the source site collection so that this information does not have to be provided – maybe I’ll do that if I feel I have the time or if people express enough interest. Note that you can specify a title and description but they’ll be overwritten during the import – I only included them so that if the import fails and you’re left with an incomplete site you’ll at least have a name for it if you should forget to delete it and stumble upon it a year later.

Figuring out how to solve all the issues surrounding converting a web to a site collection was a real pain the a$$ so any feedback that people have on this would be greatly appreciated – hopefully if there are others out there that have stumbled on this then they’ll benefit from it as well. Keep in mind also that though I think I’ve solved all the errors related to the conversion it’s possible that different implementations may have additional errors that I have not seen – if that’s the case please let me know (especially if you’ve solved the problems) so that I can share with others.

Update 9/21/2007: I’ve fixed a couple minor bugs that pop up when converting a non-publishing site. I’ve also enhanced the command to take advantage of another new command I created: gl-updatev2tov3upgradeareaurlmappings (updates the url mapping of V2 bucket webs to V3 webs thereby reflecting the change of url as a result of the move so if a user tries to hit the V2 url it will redirect to the new and updated V3 url).

Update 10/2/2007: I’ve enhanced the command to take advantage of another new command I created: gl-retargetcontentquerywebpart (fixes Grouped Listings web parts that remained pointed at the old list rather than the newly imported list).

Update 10/12/2007: I’ve removed the retainobjectidentity parameter. If you attempt to use this parameter you will receive a syntax error. Turns out that retaining the object identity when going from a sub-site to a site collection just created a nightmare. However, because I still had to handle these web parts that were broken I decided to enhance the repair routines to manually retarget the DataFormWebPart and ContentByQueryWebPart web parts. So if a matching list can be found on the source then any of these web parts on your pages should be fixed so that you don’t have to manually fix them (the gl-repairsitecollectionimportedfromsubsite command will do the same).

Update 7/6/2009: I removed the direct DB access code and added support for copying content types from the source.

254 thoughts on “Convert a Sub-site to a Site Collection

  1. One thing I forgot to mention – if you are testing the import of a web into a site collection repeatedly make sure that you delete the site collection via the Site Settings->Delete Site command and not from the central admins delete site collection command – for some odd reason the central admin tool does not clean everything up and when you do your import you’ll get even stranger behavior than the normal strange behavior (this one took me a while to figure out – I was chasing several errors that only manifest when you delete via central admin – deleting from the site itself did not result in the errors). One specific issue you’ll see is that when you view the list of content types nothing will show up – strange stuff…

  2. Thanks for the feedback – I definitly appreciate it. I do have an update – I just discovered that the global navigation is also not set correctly after the import. I’ve updated the content in the post and posted an updated version of my code.

  3. I found an issue when I tried running your convertsubsitetositecollection. It seems when the export file is created the .cmp file extension is not included in the filename variable, so when you go to import the file after creating the site an error occurs:

    Importing Site
    The file C:\Documents and Settings\spuser\Local Settings\GUID does not exist.

    Error occured importing site.

    What I did was modify the code in this section:

    string filename;
    if (!keyValues.ContainsKey(“exportedfile”))
    Console.WriteLine(“Exporting site…”);
    filename = ExportSite(sourceurl,keyValues.ContainsKey(“haltonwarning”),keyValues.ContainsKey(“haltonfatalerror”),keyValues.ContainsKey(“nofilecompression”));

    Added this line ->
    filename += “.cmp”;
    Console.WriteLine(“Site exported.\r\n”);
    } }

  4. Thanks for the info – I did most of my testing using the “nofilecompression” option as it runs a bit faster and is considered by Microsoft to be slightly more reliable (not sure why but Bill Baer recommended I use this option in preference to the compression). I added a fix that to the ExportSite static method so that it adds the extension if compression is used:

    if (!noFileCompression)
    filename += “.cmp”;

    I’ve uploaded that change so feel free to download. If you find any other issues please let me know – I’ve got so much on my plate I that I tend to forget to test some scenarios.

  5. Gary

    Another issue I am having. This one maybe my environment. When I run the command repaircollectionimported…..

    I get the follwoing error:

    Invalid URI: The Authority/Host could not be posted

    Here is the command line:
    stsadm -o repairsitecollectionimportedfromsubsite -sourceurl “http://siteA/subsiteA/” -targeturl “http://siteB/subsiteB”

    Any ideas why I am getting this error?

  6. I haven’t actually seen that particular error before. If you could step into the code and tell me on what line the error is occuring (and any other details such as method parameters, local variable values, etc.) then I could probably give you an idea of what’s happening (I’ve found that the easiest way to do this is to add System.Diagnostics.Debugger.Launch() to the Run method – this should launch your debugger (hopefully you have an environment with VS2005 on it that you can test with). My email is glapointe at edfinancial dot com – feel free to email me directly (I’ll need more specifics from you regarding the sites in order to try and replicate here – if it’s possible to send me your exported files that would really help).

  7. Forgot one more thing you can try to narrow down the possibilities – try running the FixPublishingPagesPageLayoutUrl command separate (the repair command calls this so if you can get the error with this command then we’ve at least narrowed the scope – this is assuming of course that you can’t get into the debugger which would be much easier :))

  8. Update 9/19/2007 – I fixed a minor issue with the deletesource parameter – it would only delete the source if there were no sub-webs; now it will delete the source recursively so having sub-webs no longer matters.

  9. Update 9/19/2007 – I just added another new switch “-donotcreatesite” which basically just causes the code to skip the createsite call. This is handy if you are migrating a sub-site to a root site collection and you’ve already used the extendvs command to create the web app. Note that I just discovered that going from a sub-site to a root site collection on a different web app seems to be throwing some sort of odd exception in the repair call – I’m currently working on reproducing the problem in my test environment and should hopefully have a fix soon.

  10. I figured out the problem I was having. It was pretty stupid really – I was getting an ArgumentException when checking for the existence of an item in a collection (I was looking for the return to be null). I guess I forgot that some collections (not all of them mind you) throw an exception if no match was found rather than just returning null – very annoying. Anyways, the code has been fixed and is now available. The bug was in the FixPageLayoutsAndSiteTemplates method within the main foreach loop – I just changed it to set a variable wrapped in a try/catch and that fixed it (not sure why it didn’t fail on me before because I’ve stepped into this code numerous times before – strange).

  11. Can anyone suggest how to do the reverse, ie. convert a site collection into a subsite? My subsites seem to have become individual site collections during the upgrade to WSS3.0. I used to be able to open lists on other subsites using the Data Source Catalog/Library but that doesn’t work any more.

  12. I haven’t tried it but I’ve heard that you can use the backup and restore commands to do it. I’ll probably have to play around with this very thing in the near future (if you figure it out please post back).

  13. I believe I got the custom STSADM commands installed in the GAC correctly. When I tried to run the convertsubsitetositecollection command, I got the following error:

    Value cannot be null.
    Parameter name: type

    I don’t actually see a “type” parameter in the code, so any ideas what is going on here?


  14. Thanks for the information – can be very handy from trying to migrate a sub-site as a site collection – however, what about the other way around – is there a way of migrating a site collection to become a sub-site of an existing site collection?

  15. In order to test going from a site collection to a sub-site I did a quick test which worked for me. Basically I just used the built-in export command to export the site collection and then used the built-in import command to import to a new web (after using createweb to create a shell web site). My test was pretty simple as I didn’t have any custom content types or page layouts so I’m not sure how well this works in those situations. I noticed that it did create a master pages gallery as part of the web site and it “appears” as though the pages are using that gallery rather than the site collection gallery but I haven’t looked closely enough to verify. This could be exactly what you want or it could be problematic – it really just depends on your needs. Here are the commands I used for my test which seemed to work fine:

    stsadm -o export -url “http://portal/sitecollection” -filename “c:\sitecollection” -includeusersecurity -versions 4

    stsadm -o createweb -url “http://portal2/newsubwebname”

    stsadm -o import -url “http://portal2/newsubwebname” -filename “c:\sitecollection.cmp” -includeusersecurity -updateversions 2

    I’ve updated my moveweb command to support this scenario.

    I’ve also heard that you can use backup and restore but that can’t be correct – I’ve looked into it and the restore command only allows you to restore back to a site collection so going to a sub-site does not work.

    Note that I have found one potentially significant issue with exporting your site collection – if you are using the Fantastic 40 application templates you will get an error when you do the export. The error occurs when the “Fields and Content Types for the Windows SharePoint Services Application Templates” feature is active for the site collection. This feature results in several fields being added and some of those fields are lookup fields which have their SPField.LookupList value set to a name instead of a GUID. The result is that the export fails because it can’t convert the name to a GUID (the specific error is: “Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)” and occurs in Microsoft.SharePoint.Deployment.FieldTemplateSerializer.ParseLookups()). It’s simple enough to write some code that remaps the property to point to the list ID but the problem is that the feature will add fields that point to lists that do not yet exist so you’d have to create the lists or delete the content types / fields that are not associated with a list before the export can work. As always, if anyone has some input on this please share with the rest of us.

    1. Gary, I have a requirement that I needed to move a site collection from WSS 3.0 to SharePoint 2007. For this first I created a new webapplication in SP 2007 Server and moved everything here. Everything worked fine. Then I need to move this to the existing web application in SP 2007, for this I used the above commands that you explained above, everything worked great except that it is not retaining the Master page created in WSS 3.0, when I moved to the new web application it was retaining the master page but when I moved to the existing web application it lost the master page content. In the log file it is creating the errors for not able to move the default.master page. Could you please help in this regards?

  16. Magnificent stuff. Got nailed by this and solved it via your MSDN forum post. Was going to blog it myself but then saw this.

    Impressive work.. really impressive

  17. Tom Jung:
    Thanks for your great tool, it really solve my headaches. Here is what I want to do, I’d like to have your advice.

    Goal: I have 24 subsites under a subsite (http://intranet/president) as below, and want to convert the 24 to site collections without changing the URL. and the 24 subsites have multiple subsites underneath.

    Solution: And since ‘president’ subsite is empty, I’ll create a managed path with “president”, and convert the 24 subsites to Site Collections. As you may already know my concern on “sourceurl” parameter in “repairsitecollectionimportedfromsubsite” tool, after making managed path, the source url will not available. Please let me know if you have any advice.


  18. The source url would be the url of the source site collection or a site collection “model”. This means that you can point to any site collection that has the settings the way you need/want them (page layouts and what not are present). So if “president” is your source site collection then you would use “http://intranet/president” as the source site url.

  19. Gary, this tool is fantastic! I have one site where I’m getting an error though…I think it’s not checking for null in the WebPart repair. Here’s a trace dump:

    Site imported.

    Repairing imported site…

    Error Type: System.ArgumentNullException
    Error Message: Value cannot be null.
    Parameter name: input
    Error Source: System
    Error TargetSite:System.String Replace(System.String, System.String)
    Error Stack Trace:
    at System.Text.RegularExpressions.Regex.Replace(String input, String replacement)
    at Edfinancial.SharePoint.STSADM.Commands.WebParts.ReplaceWebPartContent.ReplaceValues(SPWeb web, SPFile file, Settings settings, DataFormWebPart wp, Regex regex, SPLimitedWebPartManager& manager, Boolean& wasCheckedOut, Boolean& modified)
    at Edfinancial.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RetargetMiscWebParts(SPWeb targetWeb, StringDictionary listMap, SPFile file)
    at Edfinancial.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RetargetMiscWebParts(SPWeb targetWeb, StringDictionary listMap)
    at Edfinancial.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RetargetMiscWebParts(SPWeb targetWeb, StringDictionary listMap)
    at Edfinancial.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RetargetMiscWebParts(SPSite sourceSite, SPWeb sourceWeb, SPWeb targetWeb)
    at Edfinancial.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RepairSite(String sourceurl, String targeturl)
    at Edfinancial.SharePoint.STSADM.Commands.SiteCollectionSettings.ConvertSubSiteToSiteCollection.Run(String command, StringDictionary keyValues, String& output)
    Value cannot be null.
    Parameter name: input

    Any ideas?

  20. I’m working with Customs Border Patrol and due to the size of their site collection I need to break it down into several Site Collections, so your tool is perfect for this task, however when I try to do this many of the sites and the root site come up with file not found, but if I go to site settings URL it comes up fine, just seems to be the default.aspx pages will not load for some of the sites. Any idea where it is failing and how to fix it. Thx Peter

  21. Usually this happens when the page layout is not linked up correctly. Try running the repairsitecollectionimportedfromsubsite command and see if it fixes anything (this command should have been run automatically when you ran convertsubsitetositecollection but it can’t hurt it to try again. If that doesn’t help then I’ll need to know more information to help you further – specifically what the site structure looks like and what site templates and page layouts are in use. You can email this to me if you need to: gary at thelapointes dot com.

  22. Gary I think I fixed it, I managed to get the site settings page to resolve, and I set the Look and Feel/ Master Page to Default and forced it to reset all subsite to the same, and up she came.

    I have a little trick I learned in V2 of SharePoint that seems to still work in V3 that I will pass along. If you have an existing sub site say http”/mainsite/subsite and you create an Explicit managed path mainsite/subsite it will turn off the sub site as if it had been deleted. You can now import the subsite with your utility and create a site collection using that exact same URL space. Now here’s the good part, if you delete the managed path the subsite in all its glory will reappear, and if you add the explicit managed path back the site collection will take control and magically reappear. So you can toggle between the original subsite and the newly created site collection. I found this very valuable when I was migrating sub sites to site collections without changing the URL. It allowed me instant roll back (restore original sub site just by deleting the managed path) to the original subsite if something went wrong with the upgrade, plus uses barley noticed anything had changed. When everything is fully tested for the new site collection, simply delete the managed path which will bring back the old subsite, using site settings delete the subsite and then readd the managed path to bring back the new site collection to complete the upgrade.

  23. GeorgeS – in the download there’s a Package folder – simply install the dll into the GAC and then copy the xml file over to the 12 hives config folder (the info.txt file in the download also explains this). That’s it – once you’ve done that then you can use the commands like any other stsadm command.

  24. Hi Gary, when I try to import an exported site with import2, I get an error saying: Could not find WebTemplate IT#75804 with LCID 1033. Have you had a problem like this before? Thanks!

  25. Yeah – I’m familiar with that one – problem is that there’s no way to determine the exact template that was used to create the source – My code gets the template name and ID from the source but the ID is not always accurate (haven’t had time to figure what the deal is with that – I feel like I’m overlooking something simple though). If you encounter this then simply specify the site template to use as an argument (in your case it’s probably “IT#0”).

  26. Very cool utility. I’m trying to use the convertsubsitetocollection switch and when it tries to export the site, I get an exception saying that the “User cannot be found”. Do you know what this means?

  27. Thanks for the info. That link will do it. The server isn’t actually running MOSS 2007 yet so I can’t install SP1. I believe there is an unreleased hotfix for WSS 3.0 but the SQL methond will do just fine. Thanks again for your help

  28. Gary,

    You are freaking awesome. We had been working on a site restore issue for hours now. We were having the exact same issue with the page layouts page throwing error and then we ran into your article. It fixed out issue in two minutes.

    You are God!!!!

  29. Gary,

    I need help on installation of these controls on my SharePoint server. I read the info.txt and followed the instructions however when I run a stsadm command like convertsubsitetositecolletion I receive a command line error. What other steps are necessary to install the controls?



  30. Tim – you’ll want to make sure that the dll is in the GAC and that the xml file is in the config folder. As long as both things are set then the commands should work.

  31. Gary,

    Tim again. Its like STSADM can’t locate your command files. Do you have to copy your command files to the bin directory as well?

    I did verify that the XML file is in the correct folder and the DLL is in the GAC.


  32. Tim – if the dll is in the GAC and the commands are showing up when you do “stsadm -help” (which I saw from your other comment that they are) then I’m honestly not sure why you are not seeing anything even when you do the help command. You can try to put the dll in the 12/config/bin folder and register in the GAC from there but it shouldn’t make a difference (if it wasn’t in the GAC then you’d get some sort of Type error when you tried to use the command or get help on the command). You may want to try and re-download (maybe something just go corrupted along the way – it’s a stretch but I’m not sure what else to tell you).

  33. Gary,

    Ok…I redeployed the DLL and I am now able to get the commands to work. Hooray!

    I just attempted to perform a convertsubsitetosite collection and it performed the export but failed on the import with access denied. I have added the parameter of ownerlogin of my machine account. Do you have to specify the password? If yes on password then what is the password parameter?

    It appears that I am close now. Thanks for the support. I hope this works.


  34. The owner login just sets who the owner of the site is – you can’t set a password for it. Sounds like you just don’t have enough rights (or maybe self service site creation is disabled?). You’ll want to run these commands using your admin account (usually the one you used to setup MOSS initially).

  35. Gary,

    Can not run the command “repairsitecollectionimportedfromsubsite”. The command will not run…your command work fine but this one does not.


  36. Gary,

    Still getting file not found after running the repair command. What file or site template do you edit to set the template setting to NULL?

    With a file not found in sharepoint…is there a back door method to get to sitesettings or all site content even though the site will not render?

    Need help desparately.


  37. Tim – Are you getting any kind of error running the repair command? Also – you can email me at glapointe at statera dot com (little easier than going through the blog).

  38. Tim – for the file not found error unfortunately there’s no way that I’ve found to fix this using the browser – you might try SharePoint Designer but I suspect that will fail as well. The file not found errors are usually because it can’t find the page layout or the master page. I’ve found that some issues with the page layout are because the library doesn’t have the right content types associated with it. The repair command should fix those issues (I’ve found a couple of occasions where I had to run it more than once though it may have just been a caching issue).

  39. Gary, thanks for the custom extensions…an absolute time saver. I have just converted a subsite to a site collection using your extension as I needed to move the subsite to a new server and the backup command only works on site collections.

    Everything seemed to work fine with the exception of the Quick Link navigation. I have tried to go into Site Navigation Settings to correct the problems but am not able to change anything. All changes are ignored. However all was not lost as your enumnavigation identified the nav structure and settings and setnavigationnodes allowed me to import the correct urls via xml.

  40. Hi Gary,

    Just a quick qst, I’m redoing a customer intranet portal and have used the publishing site template as the home page and only recently noticed that I get the same error when I go to the page settings link on the toolbar. I haven’t migrated anything, it’s a from scratch thing. Does your code still apply and if so where does a non-developper put it with the least amount of mess?


  41. Michael – I haven’t seen this error occur on a straight up publishing site that hasn’t been moved or otherwise tampered with. Most likely the page layout url is pointing to the wrong place – you can try using the fix command from this post (just download the code – add the dll to the GAC and copy the xml file to the 12 hive’s config folder). There’s also some other code that may help you:

  42. Thanks for command, it save my life but i had to make some changes !

    We are french with a french installation, so “Content Type” field is named “Type de contenu” and CAML Choices has to be in french …

    Thanks for this great job, Gary !

  43. Originally posted yesterday on the import2 thread, but moved here as I decided on this command.

    I created a test web app ( with a portal site on top, then ran the command below (includes results). The command then locked up after the last warning message and did nothing for 30 minutes. I finally canceled it. Site is created and appears to have the same content as the original. I’m just not certain what the errors mean nor where that leaves things.

    stsadm -o gl-convertsubsitetositecollection -sourceurl “” -targeturl “” -createmanagedpath -nofilecompression -owneremail “” -ownerlogin “domain\spadmin” -nositetemplate -title SiteTitle
    Adding managed path…
    Managed path added.
    Exporting site…
    Site exported.
    Creating site for import…
    Site created.
    Applying site template based on source…
    Site template applied.
    Setting required features…
    WARNING: Unable to activate feature ‘PublishingSite (FeatureDefinition/f6924d36-2fa8-4f0b-b16d-06b7250180fa)’
    Provisioning did not succeed. Details: Failed to create the ‘Reusable Content’ library. OriginalException: Folders are not allowed for this list template.
    WARNING: Unable to activate feature ‘PublishingResources (FeatureDefinition/aebc918d-b20f-4a11-a1db-9ed84d79c87e)’
    Provisioning did not succeed. Details: Failed to create the ‘Reusable Content’ library. OriginalException: Folders are not allowed for this list template.

  44. Well that’s a new one – what site template is your source sub-site using? Are you able to activate teh PublishingSite feature manually using the browser or stsadm?

  45. Oh – one more thing – this may not necessarily be a bad thing – the code is trying to do it’s best to get all the features that the site “may” require based on what was configured for the parent site collection of the source sub-site – so if your sub-site doesn’t support publishing features but your parent sub-site’s site collection does then you would get an error like this because the code is doing it’s best to make sure that all features that may be getting utilized by the sub-site are reactivated at the new site collection.

  46. This whole thing was upgraded from WSS to 2003 when it came out and now to 2007. I believe the whole thing is the original team site template. I’ve nuked the test site, so I will have to redo to see if I can manually add them.

    I have had issues with trying to save lists as templates and using them where I had to go into the xml and change the version from 2 to 3 for it to work. Could be the same thing here.

  47. Can I start by echoing everyone else’s sentiment? Thank you for these extensions, they’ve saved me hours of work.

    I just wanted to point out a slight issue I had with convertsubsitetositecollection. We have a number of sub-sites created when our farm was WSS3.0. We’ve now upgraded to MOSS and want to do some re-organisation by changing the larger sites to site collections. I’ve found that after running gl-convertsubsitetositecollection the navigation is broken on the target site. As per a previous comment on this post I tried using the operation to copy navigation but sadly it still didn’t work. Current navigation was fine but the Global navigation showed tabs for everything that was in Current navigation. Trying to edit the GN in Site Settings>Navigation had no effect and I couldn’t delete the tabs either.

    I found that before running the conversion I had to modify the source site’s navigation to stop it inheriting global navigation from it’s parent site. After that everything ran smoothly!

    Thanks again and keep up the good work!

  48. After importin getting the below error.

    Progress: De-Serializing Objects to Database.
    Progress: Importing Folder /_catalogs/masterpage/Forms/Page Layout.
    FatalError: Object reference not set to an instance of an object.
    at Microsoft.SharePoint.Deployment.ContentTypeSerializer.GetContentType(SPCon
    tentType sourceContentType, ImportObjectManager importObjectManager, Boolean isP

  49. That’s an issue with the content deployment API. My suggestion would be to get in touch with Microsoft support and see if you can get the Content Deployment QFE Pack (see my last blog post).

  50. Hello Gary, I have a question regarding the use of your gl-convertsubsitetositecollection. As you can see below I’m trying to use it but get the error message listed below. Any help would be greatly appreciated. Thank you for providing the SharePoint community with these extensions!

    C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsa
    dm -o gl-convertsubsitetositecollection -sourceurl http://s3w06096:9550/ykl0/cas/wssadmin
    -targeturl http://s3w06096:9550/ykl0/wssadmin -createmanagedpath -incl
    udeusersecurity -owneremail

    Could not load file or assembly ‘Microsoft.SharePoint.Publishing, Version=12.0.0
    .0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies
    . The system cannot find the file specified.

  51. A shortfall with the gl-convertsubsitetositecollection extension which you have mentioned is that you have to provide the owner email, logging, name etc. This in my case is devastating since I need to upgrade 1000 subsites into top level sites. Is there something that can help me with this instead of having to manually go into every subsite and pick up this information. Thank you in advance.

  52. George – the error you describe typically only occurs if you are not using MOSS but rather WSS. If you are using WSS then you can just use the built-in export/import commands (at least according to MSFT – I haven’t tested it myself) – if you are using MOSS and you’re getting this error then I suggest you do a repair install.

  53. 1000 site huh? – that’s something – I’d suggest you use PowerShell for this – you can then query the information you need and then pass it into the command.

  54. Gary,

    Hello again. In running into this using STSADM, I do have some of the Fantastic 40 templates loaded and I do have the GUID error on export. So I deactivated the Fields and Content Types feature on my site prior to attempting the export. No dice. The error DOES seem to originate with the .ParseLookups() method as you suggest. I’ve also seen other posts elsewhere that I should open FIELDS.XML (in TEMPLATES\FEATURES\TSATYPES) and remove all the “{ and }” and replace them with just quotes. Any thoughts? Can you respond over eMail if possible (

  55. OK, I am getting the following error message when attempting a repair site collection

    Failed to find the XML file at location ’12\Template\Features\fcgroupslist\feature.xml’

    I do not have an fcgroupslist directory under features. Where is that coming from?

  56. Most likely there was a feature deployed at some point with that name and the site you have still has a dependency on that feature. The site may actually work just fine with that folder deleted if there was nothing in the folder that it needed to reference back to but when the repair code runs it tries to activate any features that should be active based on your source (assuming you are providing a source – if not then it’s failing because it’s trying to access a file such as a list definition or something (not directly of course – rather sharepoint is trying to access it)).

  57. First…really cool stuff.

    I have tried both the the commands with the same results. The site is working and accesable but is in a different farm. Is that an issue?

    The Web application at http://iwfe01:10801/ops/helpdesk could not be found. Veri
    fy that you have typed the URL correctly. If the URL should be serving existing
    content, the system administrator may need to add a new request URL mapping to t
    he intended application.

  58. Check your AAM (alternate access mappings) settings. Are you using host headers? How did you create the web app (via the browser or using my createwebapp command)?

  59. Since the issue appears to be with farm 1, I will start there.

    The farm 1 source site on iwfe01 is not using any host headers or AAM’s but it is using a port. The site and subsite create via broswers with sub-site in question using the Help Desk Fab 40 template. I am running the stsadm command from farm 2 and I have not installed the new commands in farm 1. Both farms have sp1 on and farm 2 has the new infrastructure updates applied.

  60. Since the problems appears to be from the source server, I will start there.

    It is not using host headers (that is why there is a port) and the sub site was created via fab 40 template. I am running the stsadm command from farm 2 (target) and the new commnands are NOT on farm 1. There is not a problem with getting to farm 1 from farm 2. Both farms have sp1 installed.

    Not sure if this answers your question.

  61. I am taking a step back before I try to “upsize” and am having problems. I am trying to backup from one farm and restore to another farm and everthing seems to be good except one thing. Any list that I used custom fields on do not work in edit/add mode nor can I configure them in the list…both throw useless errors. Once I get this working, I can use the command within the same farm and see what happens.


  62. I think I’m following what you’re saying – let me restate something so that I’m sure – you are running my custom command from farm 2 and are trying to access a web application which exists on farm 1? If that’s correct then you can’t do that – you have to run the commands from a machine that is a part of the farm in which you are trying to affect. So if you’re using the convert… command what you’ll need to do is instead use the import/export commands and then run the repair… command on the target server.

  63. By custom field, do you mean custom field types or just a new field using OOTB field types? If custom field type then make sure that you’ve installed those on the target server. Also – best practice for moving sites from one server to another is to use stsadm’s import/export commands.

  64. Ok, so I cant do it across farms.
    Yes it is a custom field type , not OOTB and I have installed them and they work fine on new list or even adding to an existing list, but the existing one do not work. I am assuming there is something registered differently when the new custom fields/solution are added to the farm which is why the existing fail but the fields do work on new list. Ok, a bit of topic but still a backup/restore issue.

    I was going to use import/export but read something that guids change and it will “mess things up”. Will you fix sub site stsadm comand handle that?

    BTW, thanks. I just find this site and I am sharing with my SPUG today!!!!

  65. My repair command will attempt to fix several of those issues. I’ve also got a custom version of the import command (gl-import2) which adds a -retainobjectidentity paramter which allows the import to occur while keeping all guids the same – note that there are a lot of circumstances where this won’t work – best thing is to just give it a try.

  66. Thanks for the feedback. I will use your commands to covert sub-site to SC after I get the restore to the new farm done.

    The problem with my custom field was an url attribute that was part of the definition and it was pointing back to the old farm and was getting a null object reference. Once we fixed that we could reconfigure the url to point to the new farm and all is good.

    Thanks and sorry about the wild goose chase.

  67. Sorry the extra post but it appears you can catch them. What appears to happen is somewhere in the conversion process the [[page]] link for the wiki converted to an href url which is not good. I checked my backup/restore which is looks good so it appears to have happened in the gl-convertsubsitetositecollection. I am going to try just and export/import and see what happens.

  68. Hello,

    first of all thanks for all those nifty commands. I love them, and they already saved me a bunch of time.

    But I am having a slight Problem with the “Convert a Sub-site to a Site Collection” operation.

    It seems to be working fine, but when I get to the point where it will repair the new site after the import, it will fail with a

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    and just do nothing.

    The owner of the new site is currently a farm admin, and stsadm is also executed as a farm admin.

    Any help would be nice

    Thanks a lot in advance

  69. Not sure why you’re getting that error. You might want to try and download the source and install the debug version which will give you the stack trace for the error which “might” help to find a solution to it.

  70. Following “Repairing imported site…” I get the error: “
    StartIndex cannot be less than zero. Parameter name: startIndex”.

    Then when browsing to the site (a Team site with Publishing enabled) I get: “An error occurred during the processing of /its/_catalogs/masterpage/default.master. Unknown server tag ‘PublishingNavigation:PortalSiteMapDataSource’.”

    Any ideas?

  71. Aaron – if you download the source and deploy the debug build then re-run the command (or run the gl-repairsitecollectionimportedfromsubsite command) it should output the stack trace which will help me troubleshoot the startindex error. As for the other error – that suggests some other issue with your environment – specifically it suggests that the publishing dll isn’t there.

  72. Gary – thanks for the reply. I downloaded the full source package, deployed from there and re-ran the “gl-convertsubsitetositecollection” (my previous version didn’t have the “gl-” commands only ones without??) which seems to have fixed the first problem.

    The problem with the second issue came to me when I remembered I had implemented making sub-sites inherit their navigation from their parent ( some time ago (thus the reference to “PublishingNavigation” in the site collection default.master).

    After fixing that I was nearly there but I see problems on some pages with references to lists etc that no longer exist (coz they are on the old site collection!). Yet another issue to address?…

  73. yeah – if you had a version without the gl- then you were about 9 months and about a hundred builds behind :). As for the references to other lists – I’m assuming list view web parts or content query web parts or something like that? Not sure if there’s anything I can give you to address that during the migration but if you can provide more details I might be able to point you to something.

  74. Gary – yes its List View and Content Query webparts that are affected. Thanks but I probably just need to plough through and change these manually. It does seem that the whole concept of copying sites around is somewhat fraught with difficulty and you seem to have swatted most if not all of the problems! Cheers.

  75. Great tool but I hit a glitch. I’m importing from an exported file and it seems to have imported several sites just fine but it always errors out on the same site:
    Value cannot be null.
    Parameter Name: g

    What’s Parameter ‘g’?

    Thanks again for this tool. you saved me soooooo much work/time.

  76. Justin – looks like a value being passed into a new GUID constructor but I’m not sure if it’s with my code or the deployment API. If you download the source you can deploy the debug build which should output a stack trace – this will help to identify where the issue is and whether or not it’s something I can fix.

  77. Gary –

    Thanks a lot for the direction. I kept troubleshooting it and found the issue. I found that it wasn’t your extensions as much as it was two of my “corrupt” lookup columns that I was trying to import. Thanks again for your time. These extensions are genius.

  78. Gary,
    I read some of the above threads regarding site collection to subsite creation. I’m trying to help a client with this issue. Here is what they are doing:

    I use the following command to export a site collection without errors:

    STSADM -o export -url “” -filename “D:\testabc.cmp” -includeusersecurity

    Next, I run the import command below:

    STSADM -o import -url “” -filename “D:\testabc.cmp” -includeusersecurity

    Usually, the import command works flawlessly. However, I ran into two websites that gave errors. I have tried numerous templates and numerous times on multiple servers, but keep receiving the same error after running import command listed below:

    [10/20/2008 1:46:01 PM]: FatalError: Value does not fall within the expected range.
    at Microsoft.SharePoint.SPFileCollection.get_Item(String urlOfFile)
    at Microsoft.SharePoint.SPContentTypeCollection.Add(SPContentType contentType)
    at Microsoft.SharePoint.Deployment.ContentTypeSerializer.CreateContentType(SPContentType sourceContentType)
    at Microsoft.SharePoint.Deployment.ContentTypeSerializer.ProcessContentType(SPContentType sourceContentType, String contentTypeXml, ImportObjectManager importObjectManager, Boolean IsParentSystemObject)
    at Microsoft.SharePoint.Deployment.ListSerializer.UpdateListContentTypes(SPList list, Dictionary`2 listMetaData, StreamingContext context, ISurrogateSelector selector)
    at Microsoft.SharePoint.Deployment.ListSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
    at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType, Boolean isChildObject)
    at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope)
    at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
    at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
    at Microsoft.SharePoint.Deployment.SPImport.Run()

    The only thing that is different on these two websites that I can find is that Variations (different languages, versions, etc.) are turned on at the site collection. Any ideas?

  79. It looks like it’s having an issue trying to find the document template associated with the content type. Take a look at the exported manifest.xml file and see if you can find what the path is to the template it’s trying to set – you might have to tweak the xml (or reset the template on the source and re-export). Also – if you can try and get the infrastructure update deployed (if you haven’t already) – there’s lots of fixes for the content deployment stuff (not sure if this is one of them though).

  80. Gary, can this be done in place? Can a web named /projects be converted into a site collection at the same location named /projects? This would require a managed path and a site collection to be created, does your code do this?

  81. Hi Gary,

    This is excellent work, but unfortunately I am in the same boat as Tim – trying to convert subsites from one farm to site collections in another. I tried running the repair command on the new site collection but it still says “The web application at (old farm) could not be found”. Is there any way around this?


  82. Gary,

    Thanks for your contributions to the SP community! I’m having a bit of trouble and hope you can help. I have a sub-site in a site collection that I am trying to move to its own site collection. The site has serveral workflows built in SPD associated with it, a couple lists with event handlers, and a custom web part. When I try to covert it, the command seems to run fine until the import where I get the following:

    [2/4/2009 3:16:40 PM]: Progress: Importing File SYSCON Followup Reports/Forms/Upload.aspx.
    [2/4/2009 3:16:40 PM]: Progress: Importing File SYSCON Followup Reports/Forms/WebFldr.aspx.
    [2/4/2009 3:16:43 PM]: FatalError: Value cannot be null.
    Parameter name: g
    at System.Guid..ctor(String g)
    at Microsoft.SharePoint.Deployment.FieldTemplateSerializer.FixLookupFieldSchema(XmlNode fieldNode, Guid parentWebId, Guid fieldId)
    at Microsoft.SharePoint.Deployment.FieldTemplateSerializer.CreateField(SPWeb web, SerializationInfoHelper infoHelper)
    at Microsoft.SharePoint.Deployment.FieldTemplateSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
    at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType, Boolean isChildObject)
    at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope)
    at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
    at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
    at Microsoft.SharePoint.Deployment.SPImport.Run()

    I checked all the lookups in the source site’s lists and they all look fine. Any help figuring this out will be greatly appreciated since I have several sites that need to be moved in a similar manner.

  83. Karel – I assume you’re using the repair command on your new farm and not using an URL from your old farm (so you don’t want to use your old farm as the source – use a site collection that reflects your old farm (same configuration) but is on your new farm). The API cannot access web applications on a different farm.

  84. Scott – lookup fields are one of those things that the content deployment API just doesn’t handle very well. One thing you might consider trying is using the stsadm export command and my gl-import2 command and use the retainobjectidentity flag – there’s several caveats to using this but in general it will either work or it won’t so it’s easy to test. If you do manage to get the import to work then you can just run the gl-repairsitecollectionimportedfromsubsite command. Also, make sure that you at least have the Infrastructure Update installed in your environment – there’s several bug fixes related to content deployment.

  85. Great work and very relevant topic.

    I’m yet to use your Utility, but suspect I’m going to need to.

    For now, I’m not even sure if it will help get us past where we are stuck.

    We have this subsite that we need to migrate to a new server in it’s own site collection. The site template is Application IT Team workspace.

    We export with version 4, but when we attempt to import, we get this on the bugs list:

    [3/5/2009 6:12:55 PM]: FatalError: Length cannot be less than zero.
    Parameter name: length
    at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
    at Microsoft.SharePoint.Deployment.ListItemSerializer.GetLookupInfoFromFieldData(Object value, Guid& lookupListId, Int32&

    Thanks for any help or information!


  86. Unfortunately the application templates (Fab 40) can’t be imported due to some craziness that msft does with the site definitions – they basically violate the schema definition by hacking list and lookup values which the content deployment API can’t handle – if you search around I think there are some folks who have found workarounds – I’ve not looked recently though.

  87. Gary,

    first off, good job. I am trying to move a subsite to its own site collection, but running into a problem during the import phase.

    I should clarify that this subsite and the new site collection are all on the same farm. It was also originally set up for FBA (Forms Based Authentication) but I have switched it back to Windows for the import/export due to me receiving errors with the -ownerlogin parameter of the command.

    This is what I see as the last steps in the log, but frankly, I am clueless as to what it’s trying to do at this point, other than trying to import the content. It appears to have brought over all users and roles correctly. Any ideas of what to look at?

    [3/25/2009 2:36:56 PM]: Progress: Starting content import.
    [3/25/2009 2:36:56 PM]: Progress: De-Serializing Objects to Database.
    [3/25/2009 2:36:56 PM]: FatalError: Object reference not set to an instance of an object.
    at Microsoft.SharePoint.Deployment.RolesImport..ctor(ImportStreamingContext context, SPSite site, SPWeb web, XmlReader xr, Int32 iBatchSize)
    at Microsoft.SharePoint.Deployment.SecurityObjectSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
    at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObjectDirect(Object objParent, Type objectType)
    at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope)
    at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
    at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
    at Microsoft.SharePoint.Deployment.SPImport.Run()
    [3/25/2009 2:36:56 PM]: Progress: Import Completed.
    [3/25/2009 2:36:56 PM]: Finish Time: 3/25/2009 2:36:56 PM.
    [3/25/2009 2:36:56 PM]: Completed with 0 warnings.
    [3/25/2009 2:36:56 PM]: Completed with 1 errors.

  88. Great stuff Gary, we’ve used several of your extensions, and really appreciate it. A couple of issues though I’d like to ask you about. 1) I’m getting a message that “The file “_catalogs/masterpage/file.aspx” is checked out or locked for editing by Sharepoint\system” when using the gl-repairsitecollectionimportedfromsubsite. The problem appears to be occurring at line 571. It’s trying to do a file.Checkout() on the layouts but they are already checked out from when they were added to the _catalogs/masterpage directory.

    I tried to setup the project in VS2008 and start the debugger, but had trouble getting the debugger symbols to show, and could not get attached to the process. Do you have any documentation on how to do that.

    Thanks for your help and your stuff is awesome. Really appreciate it.

  89. To step through the code just build the debug build of the source (depending on your OS and whether gacutil is installed you might have to manually GAC the built dll). Then just run the command with the -debug switch – it will launch the debugger for you.

  90. Gary,

    I was able to successfully run your utility and created site collection.
    What i was not able to get is that are you generating any file while export and import process.
    What is the background process for the same?
    Please let me know.

  91. I’m not entirely sure what you are asking about but if you are wondering if the export generates files that are then imported, then yes – that is true. There is no background process for handling these files though.

  92. Gary, thanks for your quick reply.
    But what i wanted to know is that where are the export files generated? What is the path to check for the generated files?
    I am not getting the generated files. Can you please tell me?

  93. Gary, do you have any idea about host named site collection.
    If yes, can you explain about the same via commands (full procedure).
    Also how to get/create multiple root level site (not inside sites) over a single web application?

  94. Hi Gary, as usual your custom commands have managed to save my life.

    My test scenario worked briefly with the exception of a failed feature which I simply activated on the destination site collecton.

    Now, for my production scenario I have a few other requirements and am hoping you can provide the right sequence of commands and parameters.

    We have a team site (publishing enabled) with several subsites which has grown to almost 15GB. I want to re-provision this as the root site in a clean webapp at e.g.

    As an added bonus I’d also really, really like to give it it’s own content database.

    Can this be managed do you think? Perhaps adding a -newcontentDB flag to this command would be an asset in this situation?

    I look forward to your comments.

  95. Use the stsadm createsiteinnewdb command to create the site collection but don’t specify the site template. You should then be able to use this new sc as the target in the convert command.

  96. Hi Gary,

    I have to do this for a couple of WSS 3.0 subsites that I want to turn into top-level sites. Will it work ? If not, do you know the best way to do it ?


  97. Yes, you can use this command to do what you want though for straight up WSS sites (non-publishing sites) you don’t need it (you can use stsadm export/createsite/import to do what you want (don’t specify the site template on the createsite). My command will just save you some steps. If you want to use mine I suggest you wait a couple hours and download the latest (I have an updated build that I’m about to push out that removes the database access calls and improves a couple other minor things thus making the command fully supported now). I’ll post something via twitter when I’ve pushed the build out.

  98. Hi Gary,

    Sorry, I don’t do Twitter. 🙂 Was this upgraded so as to be a supported approach?

    If so, do I just download and upgrade the MOSS Only STSADM Extensions (x86, x64) commands file?

  99. Hi Gary, just running the latest version of gl-convertsubsitetositecollection (say that 3 times quickly) and it’s asking for the createsiteinnewdb or createsiteindb parameter.

    Looks like you added these in after all! Thank you. That’s anothr step taken care of. 😀

  100. Hmm. Either I’ve done something silly or the createsite parameters need to be called first.

    Everything looked good until the creat site moment.


    stsadm -o gl-convertsubsitetositecollection -sourceurl “https://server/restore” -targeturl “https://server/path/new” -nofilecompression -owneremail -ownerlogin domain\me -createsiteinnewdb -databasename “newdb”

    Exporting site…

    Site exported.

    Creating site for import…

    Another site already exists at https://server/path/new. Delete this site before attempting to create a new site with the same URL, choose a new URL, or create a new inclusion at the path you originally specified.

    Error occured creating site.
    COMMAND: -o createsiteinnewdb -url “https://server/path/new” -owneremail “” -databasename “newdb” -ownerlogin “domain\me”


    Now I definitely didn’t create the site in advance. Investigation revealed that a blank collection was created at the specified path. A new content DB was also created but the site wasn’t created in it.

    I then deleted the new collection (properly) and used the -createsiteindb parameter to see if I can get it created where I need it.

    Success! A few settings tweaks and I have a new site collection in specified database from a subsite with publishing enabled.

  101. OK. I’ve been through every site setting and the only thing retunring an error is the page-level settings.

    I can’t seem to resolve this with the usual pagecontact or layoutpage fixes and there’s very little on the Web.

    Any advice appreciated.


    Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e)
    at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
    at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
    at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
    at System.Xml.XmlDocument.Load(XmlReader reader)
    at System.Xml.XmlDocument.LoadXml(String xml)
    at Microsoft.SharePoint.Publishing.PublishingWeb.GetAvailablePageLayouts()
    at Microsoft.SharePoint.Publishing.PublishingWeb.GetAvailablePageLayouts(SPContentTypeId associatedContentTypeId)
    at Microsoft.SharePoint.Publishing.Internal.CodeBehind.PageSettingsPage.GetAvailableLayouts()
    at Microsoft.SharePoint.Publishing.Internal.CodeBehind.PageSettingsPage.LoadLayoutValues()
    at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.LoadValues()
    at Microsoft.SharePoint.Publishing.Internal.CodeBehind.PageSettingsPage.LoadValues()
    at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.OnLoad(EventArgs e)
    at Microsoft.SharePoint.Publishing.Internal.CodeBehind.PageSettingsPage.OnLoad(EventArgs e)
    at System.Web.UI.Control.LoadRecursive()
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

  102. Not sure why you got the error with the creating a new db but I’ll see if I can figure it out tomororw. The other error is specifically related to the direct db access code that I removed – if you have SP2 it should work for you (compromise was to leave it in and deal with support issues or pull it and expect SP2). If you have SP2 then I’ll have to research more – it worked in my testing. With SP2 make sure the PublishingResources feature is activated (if you install SP2 just re-activate this feature). Essentially the problem is that the ContentType field in the masterpage library should be a Choice field but it comes through as a Text field pre-SP2.

  103. Hi Gary, we’re running which I believe is SP2.

    I can’t find a feature specifically named Publishing Resources.

    The ‘Office SharePoint Server Enterprise Site Collection’ feature was already enabled at the site collection level.

    And I also enabled Office SharePoint Server Publishing at the site level. However the error persists.

    The Pages library didn’t inherit our custom content types. This in itself was no big deal but I wonder if it’s related at all?

  104. That version is SP2. PublishingResources is hidden – you’ll have to go to the command line and use stsadm to activate it (it should be activated by one of the features you mention though (can’t remember which)). What site def was your source sub-site and source root site collection based on?

  105. HI, OK. I found that feature and other hidden ones using SWAT. Yes, I believe it woul dbe activated by the other publishign features as well.

    The template was STS#1 team site.

    I only specified a sub-site as the sourceurl, not a model site collection. I thought this was an option or did I misread that??

  106. The code will take the site collection of whatever source URL you specify (so if you specify the source URL as a sub-site it will look up the chain to the root site collection to get any needed resources.

  107. It inherites resources? That’s brilliant. The beauty iof your solutions always lies in the elegance.

    Incidentally, disregard the Page content types issue. I forgot to apply them first at source. :*

    Looking forward to any updates on the Page Settings error. In the meantime I’ll keep digging.

  108. Not so much inherits as consumes (though in regards to content types inherits is correct). There are some publishing features that are scoped at the site collection level – sub-sites may be dependent on those features existing (think page layouts for example). So when you convert a sub-site to a site collection you have to make sure your new site collection has all the dependent assets from the source site collection. If you could let me know what site template the root of your site collection is using then I will see if I can reproduce the issue (if you download my code and uncomment the db access code in the repair command then it should fix the issue but I’d like to work with you to figure whats going on so that I can leave that code commented out.

  109. Hi Gary, tahnks for your continued support. Site details are as follows.

    sts#1 = Subsite used as sourceurl
    sps#0 = Site collection parent of sourceurl

    Destination site correctly uses the team site template.

    I’m wondering if it mightn’t be easier to start again.

    – Create new SC using sts#1 and use this as the sourceurl “model site collection”.
    – Add the -exportedfile paramater and point to a CMP of the team site.

    Is this the intended use for this parameter?

  110. Yes, all required features were enabled. Wish I could give you RDP access. 🙂

    Please let me know if you would prefer to take this offline and I can email through any screenshots or other settings info that might help.

  111. Offline would probably be better – you can get my email via the “Contact” tab at the top of the page. I don’t suppose there’s a chance I could get a backup of your source site collection (minus any confidential data of course)? Also, can you get me the schema for the ContentType field of the masterpage gallery (you can use SharePoint Manager 2007 to pull that info). I’ve setup my environment to match the info you’ve given me so far and I’ve yet to be able to reproduce the problem…

  112. Hi Gary, it’s been a few weeks since I performed my site promotion and I’ve run into a curious issue.

    Neither of the subsites promoted to site collections are getting synched with the SSP and My SharePoint Sites list.

    I’ve checked the logs and the errors seem to point back to the new databases they were created in.

    User Profiles Synch WebApp [myWebApp] to Content DB [myContentDB] – Failed

    ProfSynch: The site with ID 8bf9c44e-ccf2-46dc-9631-bdc9da7977d9 cannot be synchronized due to an unprovisioned root web
    at Microsoft.Office.Server.UserProfiles.SiteSynchronizerCollection.GetSynchInfoForSite(SqlDataReader dr, SynchInfo info)
    at Microsoft.Office.Server.UserProfiles.SiteSynchronizerCollection.<get_Elements>d__0.MoveNext()

    And an error for every form view in the new sites. e.g.

    w3wp.exe (0x2B1C) 0x29D8 Windows SharePoint Services
    General 8kh7 High
    There is no Web named “/[myNewSite]/Shared Documents/Forms/AllItems.aspx”.

    Could this be related to running this command or do I have another problem?

  113. First of all thanks for providing such nice stsadm extensions…

    However when I try to use gl-convertsubsitetositecollection, it throws an error as below…

    Any help is much appreciated…

    Note:- I am trying to create sitecollection on a blank webapplication.

    Error: The file cannot be imported because its parent web /intranettest does not exist.
    [8/13/2009 4:50:10 PM]: FatalError: The file cannot be imported because its parent web /intranettest does not exist.
    at Microsoft.SharePoint.Deployment.FolderSerializer.GetParentWeb(SerializationInfoHelper infoHelper, ImportObjectManager objectManager)
    at Microsoft.SharePoint.Deployment.FolderSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
    at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType, Boolean isChildObject)
    at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope)
    at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
    at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
    at Microsoft.SharePoint.Deployment.SPImport.Run()
    [8/13/2009 4:50:10 PM]: Progress: Import Completed.

  114. Hello,

    how can I use stsadm –o gl-repairsitecollectionimportedfromsubsite

    for the existing site, when I don’t want to re-import it again.

    do you provide any extension to fix error without making another stadm import?!

    I’m asking because client made a lot of customizations and they want to fix existing problem without reimporting it

  115. Thanks for all your contributions to the overworked SharePoint admin community Gary. 🙂 I had one question about the custom stsadm command. Does it bring the entire user information list over from the “source” site collection to the new one when you move a subsite? If so, is there a way to get it only to bring users specifically listed on the ACLs for the subsite? This would be a huge win for us in trying to split up an overgrown site collection with a nightmare of a user information list.

  116. Man Uyou are really made my day worth. Thanks alot for this command it save me from so many hecks. i had the dev environment with sp2 and prod sp1 i have to move the site coolection and your command works like a charm i ahd back up the site collection and restore it as subsite using SPD and then convert that site using ur command it works awesome.
    Thanks for this great utility.

  117. I believe it will bring all users over – this process is controlled by the content deployment API and nothing specific that I’m doing so there’s not much I can do to fix it. You’d have to clean up the users before migrating.

  118. this tool sounds amazing and is just what I need, problem is my site is in hebrew (that is rtl under 1037 directory) and it seems to be causing problems already in the beginning of the process, just to give you a clue this is the first error I get when running your command: Feature ‘d8d8df90-7b1f-49c1-b170-6f46a94f8c3c’ for list template ‘1104’ is not installed in this farm. The operation could not be completed.
    Error occured exporting site.
    COMMAND: -o export -url “http//source” -includeusersecurity –
    versions 4 -quiet -filename “C:\Users\administrator.MYDOMAIN\AppData\Local\Tem

    do you have any idea as to why this is happenning? any help would be greatly appreciated!

  119. Looks like you have a custom feature that’s been uninstalled without being deactivated from the site. You’ll need to re-install the feature or try and deactivate it.

  120. thanx for the fast reply – you were right. now I managed to fix that and ran ur command it did the export but then fell when trying to create a site in the location I specified, it said I first had to delete the site. so I went to the site and deleted it but then I had to continue running the commands manually, everything worked until the import command it took me a while to find the cmp files once I found them it keeps on giving me a “The directory “c:/XXX” does not exist” error – do you think you know why? have I missed something?
    again I thank you for your time and help

  121. It would end up running the export again but you can just run the convert command again (or pass in the path the exported files into the convert command and it will use that instead of exporting again). As for the error – just make sure you have the path to the directory correct and that you are property setting the nofilecompression parameter.

  122. Hi Gary:
    What steps can I take to figure out where I am going wrong?

    All I get from stsadm is: ‘Command Line error’ along with a listing of the -o commands including the gl- list, and example usage.

    My command looks like:
    C:\>stsadm -o gl-convertsubsitetositecollection -sourceurl
    5500/ZX/ -targeturl -createmanagedpath -nofilecompre
    ssion -owneremail -ownerlogin aDomain\xtAdmin -createsitein
    db -databasename WSS_Content_DB2

    Thank you.


  123. Dont need to all this.
    Simply Deactivate and reactivate Site Publishing Features under Site Administration->Site features->Office SharePoint Server Publishing[Deactive first and then Activate].


  124. I am running into some of the issues with subsites imported to site collections. I cannot run the gl_repairsitecollectionimportedfromsubsite successfully on any site imported in this manner. I experience three different errors:

    Some hang at:
    Progress: End fixing page layouts and site templates

    Some crash at:
    Progress: Importing List Master Page Gallery
    FatalError: Cannot complete this action

    Others crash at:
    Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
    Please try again
    at Microsoft.SharePoint.Library.SPRequest.SetListContentTypes(…

    Is there anything I can possibly do to get this command to run without these errors?

  125. Unfortunately there’s just not enough information for me to help you. Your best bet would be to debug the code using Visual Studio and see what’s happening (the code works for me in my test cases).

  126. Hey Gary – it’s jason kaczor here, I am getting the exact same behaviour – hang with no errors. Unfortunately this is a production environment – no debugging. MOSS x64, SP2, Dec 2009 CU.

  127. Hi Gary, i am using the gl-convertsubsitetositecollection command. Does this command use any temp space in C:\? After running this command, my C:\ space was reduced dramatically. Thanks.

  128. Yes – the exported site is stored in a temp path on the root. You manually export the site and use the exportedfile parameter to use those files rather than have it export and save to the root.

  129. Hi Gary, will the exported site in the %systemroot%\temp be automatically deleted after the import?

    Strange, I have use the -exportedfile parameter, and my C:\ space was reduced also.

  130. I chose not to delete it in case the user needed to retrieve the exported files. As for the space still being taken up – it could be from the ULS logs, the exported site is all I put on disk so if you’re using the -exportedfile param then I’m not directly writing anything.

  131. Thank Gary for the response. Well, if I want to delete away the exported file in C:\ to free up space, where exactly is the path? I can’t seem to locate it in C:\temp or C:\windows\temp. Thanks very much.

  132. Great tool. Now if I can only get it to work. 🙂

    I get:

    Progress: Begin adding missing features…
    Progress: Activating site scoped feature “Reporting”..
    Progress: End adding missing features.
    Object reference not set to an instance of an object.

    stsadm -o gl-repairsitecollectionimportedfromsubsite -sourceurl -targeturl

    Doesn’t seem to matter what source website I choose.

  133. If you have SharePoint dev machine can you rebuild the project in debug mode and re-deploy? This will give you a stack trace which I can use to, hopefully, fix the issue you’re seeing.

  134. Not sure why it is giving me warnings on my references but here is my output when I try to rebuild.

    Error 1 An error occurred while validating. HRESULT = ‘80004005’ E:\Sharepoint Development\Lapointe.SharePoint.Automation\Lapointe.SharePoint.PowerShell.Commands.Setup\Lapointe.SharePoint.PowerShell.Commands.Setup.vdproj Lapointe.SharePoint.PowerShell.Commands.Setup
    Error 2 An error occurred while validating. HRESULT = ‘80004005’ E:\Sharepoint Development\Lapointe.SharePoint.Automation\Lapointe.SharePoint.PowerShell.Commands.Setup64\Lapointe.SharePoint.PowerShell.Commands.Setup64.vdproj Lapointe.SharePoint.PowerShell.Commands.Setup64
    Warning 3 All custom dialogs must precede the ‘Installation Folder’ dialog. E:\Sharepoint Development\Lapointe.SharePoint.Automation\Lapointe.SharePoint.PowerShell.Commands.Setup64\Lapointe.SharePoint.PowerShell.Commands.Setup64.vdproj Lapointe.SharePoint.PowerShell.Commands.Setup64
    Error 4 An error occurred while validating. HRESULT = ‘80004005’ E:\Sharepoint Development\Lapointe.SharePoint.Automation\Lapointe.SharePoint.PowerShell.Commands.Setup64\Lapointe.SharePoint.PowerShell.Commands.Setup64.vdproj Lapointe.SharePoint.PowerShell.Commands.Setup64
    Error 5 The command “cd E:\Sharepoint Development\Lapointe.SharePoint.Automation\Lapointe.SharePoint.STSADM.Commands\
    Install.bat “E:\Sharepoint Development\Lapointe.SharePoint.Automation\Lapointe.SharePoint.STSADM.Commands\bin\DebugWSS\Lapointe.SharePoint.STSADM.Commands.dll” DebugWSS
    ” exited with code 1. Lapointe.SharePoint.STSADM.Commands
    Error 6 The OutputPath property is not set for this project. Please check to make sure that you have specified a valid Configuration/Platform combination. Configuration=’Debug’ Platform=’AnyCPU’ Lapointe.SharePoint.PowerShell.Commands
    Warning 7 The referenced component ‘Microsoft.Office.Server’ could not be found.
    Warning 8 The referenced component ‘Microsoft.SharePoint’ could not be found.
    Warning 9 The referenced component ‘System’ could not be found.
    Warning 10 The referenced component ‘System.Configuration.Install’ could not be found.
    Warning 11 The referenced component ‘System.Management.Automation’ could not be found.
    Warning 12 The referenced component ‘System.Web’ could not be found.
    Warning 13 The referenced component ‘System.XML’ could not be found.
    Warning 14 The referenced component ‘System.Xml.Linq’ could not be found.
    Warning 15 The referenced component ‘System.Data.DataSetExtensions’ could not be found.
    Warning 16 The referenced component ‘System.Data’ could not be found.

    Got any ideas why these errors are happening

  135. I was getting all those messages too for my build. 😉

    The references worked themselves out…(I first tried to add them all..but then restarted..)

    I had to change from ANYCPU and put in X86 – since this is my test environment unfortunately. 🙂

    I then had to make sure PowerShell was set to run scripts (it was restricted) and change a few other settings (unassigned variables…and ad a \x86 to a path…)

    What are the next steps after a successful build?

  136. You don’t need the pdb in the GAC (just there for debugging) – I’ll try to take a look at the code this week – I thought I had it outputting the stack trace when in debug mode but maybe I’m thinking of a different cmd?

  137. Here is some more food for thought:

    C:\>stsadm -o gl-repairsitecollectionimportedfromsubsite -sourceurl “” -targeturl “https://sps” -debug

    Progress: Begin adding missing features…
    Progress: Activating site scoped feature “Reporting”…
    Progress: End adding missing features.
    Object reference not set to an instance of an object.

    C:\>stsadm -o gl-convertsubsitetositecollection -sourceurl “” -targeturl “
    ttps://” -owneremail “”

    Exporting site…

    Site exported.

    Creating site for import…

    An owner login is required since this web application is not in Active Directory account creation mode.

    Error Type: Microsoft.SharePoint.SPException
    Error Message: Error occured creating site.
    COMMAND: -o createsite -url “” -owneremail “”
    Error Source: Lapointe.SharePoint.STSADM.Commands
    Error TargetSite:Void CreateSite(System.String, System.String, Lapointe.SharePoint.STSADM.Commands.OperationHelpers.SPP
    Error Stack Trace:
    at Lapointe.SharePoint.STSADM.Commands.SiteCollectionSettings.ConvertSubSiteToSiteCollection.CreateSite(String sourc
    Url, String targetUrl, SPParamCollection Params)
    at Lapointe.SharePoint.STSADM.Commands.SiteCollectionSettings.ConvertSubSiteToSiteCollection.Execute(String command,
    StringDictionary keyValues, String& output)
    Error occured creating site.
    COMMAND: -o createsite -url “” -owneremail “”

    (you can contact me directly at the above email)

  138. immisGary,

    Sorry it took so long for me to get you my call stack but here it is.

    Lapointe.SharePoint.STSADM.Commands.dll!Lapointe.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.AddMissingFeatures(Microsoft.SharePoint.SPSite sourceSite = {SPSite Url=http://Dev}, Microsoft.SharePoint.SPWeb sourceWeb = {BPM}, Microsoft.SharePoint.SPSite targetSite = {SPSite Url=http://Dev/americas/test}, Microsoft.SharePoint.SPWeb targetWeb = {Test}) Line 762 + 0x56 bytes C#
    Lapointe.SharePoint.STSADM.Commands.dll!Lapointe.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RepairSite(string sourceurl = “http://Dev/BPM”, string targeturl = “http://Dev/americas/test”, bool verbose = true) Line 103 + 0x15 bytes C#
    Lapointe.SharePoint.STSADM.Commands.dll!Lapointe.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.Execute(string command = “gl-repairsitecollectionimportedfromsubsite”, System.Collections.Specialized.StringDictionary keyValues = {System.Collections.Specialized.StringDictionary}, out string output = “”) Line 82 + 0x12 bytes C#
    Lapointe.SharePoint.STSADM.Commands.dll!Lapointe.SharePoint.STSADM.Commands.OperationHelpers.SPOperation.Run(string command = “gl-repairsitecollectionimportedfromsubsite”, System.Collections.Specialized.StringDictionary keyValues = {System.Collections.Specialized.StringDictionary}, out string output = “”) Line 222 + 0x29 bytes C#

    Any direction on this is appreciated

  139. Hey Gary,

    This was a great post. And now I am trying to use this. My requirement is that I need to export 300 sites in 3 site collections (all 3 on 1 web application – say “webapp1”) to 300 individual sitecollections(all 300 to the same web application -“webapp1”). Kindly help me on how I can automate it using your stsadm extensions with some custom coding.

  140. Hi Gary,

    I am trying to use gl-repairsitecollectionimportedfromsubsite, as it sounds exactly what I need (breaking 30 subsites in to sites). Unfortunately I am unable to get the command to run. I have even ran a test using your stsadm commands testweb and testsite, to try and minimise the chance of it being a syntax error on my part.

    I can run some of the gl- commands, but not gl-repairsitecollectionimportedfromsubsite, even -help gl-repairsitecollectionimportedfromsubsite does not return the help, just “command line error.”

    Running stsadm -o gl-enumfeatures -url http://sitename works , so I am at a loss as to why repairsitecollectionimportedfromsubsite do not.

    Any helpful pointers?

  141. Naythan, have you actually converted the Web (subsite) to a Site Collection (site) as yet? Or are you trying to run this command on a Web?

    If not, you need to run the convert subsite to site collection command first. Only run this command on the promoted site if you run into trouble.

    At least I believe that’s how it works. Please feel free to correct me if I’m wrong Gary!

  142. Raghavendra – you can do this pretty easily with PowerShell. You just need to get the SPSite source site collection, loop through all the webs you want to convert and then call the stsadm command.

  143. Took backup of site from one web application and restored as top level site on new web application. Now when i click on Create Page, I gives this error : “data at the root level is invalid. line 1 position 1”

    My source subsite is in production. I took backup of that and restored that as site collection in my Test environment. Then when i am trying “create page” i hit the error.

    Downloaded and deployed Lapointe.SharePoint.STSADM.Commands.wsp (IN TEST ENVIRONMENT)

    Now i have to try the command
    stsadm.exe -o gl-repairsitecollectionimportedfromsubsite –sourceurl “url” –targeturl “url”

    It is failing saying the source url is not available. I am sure this is because, it cant access the Site in the Production. Can somebody please eloborate more on this and help me ?

  144. Jag – if your source site is in a different farm then you need to use a local source site which can be used as a model site – essentially you need a site that has the same basic configuration (same masterpages and pagelayouts and features specifically – it doesn’t have to be the same site as long as the site collection contains enough information to help repair the new site collection).

  145. Hi Gary!

    Amazing extensions that you have built!

    I’m having some problems with the export and import. I’m trying to export a subsite and import it as a site collection, say from http://urlsite/sitename to http://urlsite/sites/sitename.

    Progress: Importing List .
    FatalError: Specified method is not supported.
    at Microsoft.SharePoint.SPList.set_MajorVersionLimit(Int32 value)
    at Microsoft.SharePoint.Deployment.ListSerializer.UpdateListData(SPList list,
    Dictionary`2 listMetaData, SPImportSettings settings)
    at Microsoft.SharePoint.Deployment.DocumentLibrarySerializer.UpdateListData(S
    PList list, Dictionary`2 listMetaData, SPImportSettings settings)
    at Microsoft.SharePoint.Deployment.ListSerializer.SetObjectData(Object obj, S
    erializationInfo info, StreamingContext context, ISurrogateSelector selector)
    at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType,
    Boolean isChildObject)
    at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type object
    Type, Boolean isChildObject, DeploymentObject envelope)
    at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializat
    at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serial
    at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReade
    r xmlReader)
    at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
    at Microsoft.SharePoint.Deployment.SPImport.Run()

    I’ve used your extensions and the error stays the same.
    I surfed the net and it seems to be that on that list i have to enable versioning, export the site,import the site and everything goes fine…until another list has the same problem, and then i have to start all over again.
    Have you ever found this error?I cannot find any solution for this


  146. Hi Gary!

    thanks for the quick reply.
    I’m only running SP1.
    I thought about that also but i find weird that there’s not much information about this error on the internet.

  147. The infrastructure update came out after SP1 and the bulk of that update was to fix issues related to content deployment. I’d strongly suggest you go to SP2 and see if you still have the issues.

  148. Gary,

    I have converted a subsite to a sitecollection. Thet original sitecollection is lcid 1033 en the subsite was lcid 1043. The convert finalized ok, but not all content types and the masterpage definitions were set correctly. Now I have excecuted the command gl-repairsitecollectionimportedfromsubsite and it stops at creating content type System with the error object reference not set to an instance of an object.

    Do you have any idea what is the problem I think it is lcid related.

  149. Henk – I suspect it has something to do with switching the lcid of the root site but I’ve honestly never tested this scenario. If you are able to use the debug build of the tool and can get me a stack trace I might be able to fix it.

    I honestly haven’t had a lot of time to look at some of the issues with the extensions lately (working on a book plus lots of other stuff so I’ve been unusually bad about making fixes to the tools – hoping to have some time in the near future but for now they’re kind of on the back burner for me).

  150. Hey Gary, first off, thanks for your contribs to the SP community, it is greatly appreciated.
    I am trying to move a large web to its own site collection in a different content database, the export works okay but I get the fatal exception :
    FatalError: Item does not exist. It may have been deleted by another user.
    at Microsoft.SharePoint.SPListItem.EnsureItemIsValid()

    during the import process, what I would really like to do is to have such errors logged and the import continue…any ideas? Thanks in advance!

  151. SharePointWale – unfortunately I’m just using the OOTB content deployment API to do the export and import so I can’t control how it handles the errors. I suspect that with this specific issue it is trying to locate something in the root web (from the source) and it’s not finding it – perhaps you have a lookup column pointing to a list in the root web (or another peer web) or a list view web part or some other artifact like that.

  152. Hi Gary,

    We are using your convertSubsiteToSiteCollection and it has saved us lot of custom coding. But we just realized that there is no -versions attribute.

    Is the default for versions is 4? Do we export the subsite first and then run command if we want it to be any other version?


  153. Hi,

    is there a way to pipe the exported files to another destination instead to the user profiles temp directory??

    Best regards

  154. I believe that I’m exporting all versions. In any case – if you need more control you can always just do the export/import manually and just run the repair command.

  155. Does this conversion include any alerts that users have setup? I’m working with a business team that needs to have their site converted in this way, but we are trying to make it as transparent to them as possible. Requiring all users to recreate their alerts is not ideal. As a related question – are alerts in any way associated with the site itself, or are they associated with the user profile?

  156. Hi Gary,
    Used the verbose command with convertsubsitetosite extension and I am getting this error:

    Progress: Setting available page layouts…
    Progress: End fixing page layouts and site templates.
    The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

    The global navigation is not fixed after the import. I installed the wsp on the WFE server. Is this due to setup issues or something else ?

    Meanwhile I am trying to go through the code to see which file it is accessing.


  157. Alerts don’t migrate (nor do recycle bin items, workflows, and personalization settings). This is a limit of the content deployment API which I’m using to do the migration.

  158. This is throwing a file not found exception for me. Adding printfs has narrowed it down to somewhere inside RepairSiteCollectionImportedFromSubSite:FixPageLayoutsAndSiteTemplates (line 524) I believe. I’m using a version I downloaded today.

    Partial traceback:

    at Microsoft.SharePoint.Publishing.Internal.LongRunningOperationJob.Start(SPWeb currentUserWeb)
    at Microsoft.SharePoint.Publishing.PublishingWeb.PushdownInheritanceOfAvailablePageLayouts(Boolean useSynchronous, String succe
    ssUrl, String failureUrl, LroWssAreaPropertyPushdown previousJob, Boolean throwExceptionOnFailure)
    at Microsoft.SharePoint.Publishing.PublishingWeb.PushdownInheritanceOfAvailablePageLayouts(Boolean useSynchronous, String succe
    ssUrl, String failureUrl, Boolean throwExceptionOnFailure)
    at Microsoft.SharePoint.Publishing.PublishingWeb.SetAvailablePageLayoutsString(String pageLayouts, Boolean resetAllSubsitesToIn
    at Microsoft.SharePoint.Publishing.PublishingWeb.AllowAllPageLayouts(Boolean resetAllSubsitesToInherit)
    at Lapointe.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.FixPageLayoutsAndSiteTemp
    lates(PublishingSite sourcePublishingSite, PublishingWeb sourcePublishingWeb, PublishingSite targetPublishingSite, PublishingWeb t
    argetPublishingWeb, SPSite targetSite, SPWeb targetWeb)
    at Lapointe.SharePoint.STSADM.Commands.SiteCollectionSettings.RepairSiteCollectionImportedFromSubSite.RepairSite(String sourceu
    rl, String targeturl, Boolean verbose)
    at Lapointe.SharePoint.STSADM.Commands.SiteCollectionSettings.ConvertSubSiteToSiteCollection.Execute(String command, StringDict
    ionary keyValues, String& output)
    The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

  159. I thought at first the problem was that this line (c. 540 in RepairSite…)

    if (!string.IsNullOrEmpty(targetWeb.AllProperties[“__PageLayouts”] as string))

    needed to have targetWeb.AllProperties.HasKey(“__PageLayouts”) added to it, but not so.

    The problem is, as the preceding callback trace showed, that the AllowAllPageLayouts is throwing an exception.

    The first solution to occur to me is to add a PublishingWeb.IsPublishingWeb(targetWeb) protecting if block.

  160. AllowAllWebTemplates also throws an exception when called on a non-publishing web; perhaps the entire FixPageLayoutsAndSiteTemplates method is problematic.

  161. The SetGlobalNavigation call probably also needs to be protected, e.g., c l 163

    if (PublishingWeb.IsPublishingWeb(targetWeb))

  162. gl-convertsubsitetositecollection finally succeeded, with my fixes described above. They’re simple fixes, but I’d be happy to send you a copy if that would help get them fixed in your trunk.

    And thanks for making this great software available!

  163. I’d be happy to send you fixed code, or a patch file, but I have no email address. May I send you some fixed code (b/c I’d love to get this fixed in your trunk version)?

  164. I have upgraded a site to a site collection and now cannot create pages. I ran the command gl-repairsitecollectionimportedfromsubsite and it starts fine but finishes with “Index (zero based) must be greater than or equal to zero and less than the size of the argument list.”


  165. Is there any kind of stack trace being output (I can’t remember if I had one dumping or not). Most likely the issue is with the page layouts–they’re probably just not getting fixed correctly for some reason.

  166. Hi,
    Very very good/relevant/useful information.
    I have a question. I didn’t get anywhere in place.
    I am also doing the same things. BUT i am unable to think about the implications on the security aspects as :
    1. Many subsites/lists will have unique permissions
    2. there are many SharePoint groups created at subsite levels
    3. Users are added into those groups
    4. I also got one fatal error related to security groups

    I will appreciate if you can tell us a littel about about this…

    Email id –

  167. When i set the __Layouts property then “Data at…” error resolved but now when click on OK button then it gives me below error:

    Object reference not set to an instance of an object. at Microsoft.SharePoint.Publishing.PublishingWeb.GetAvailableWebTemplatesString(SPWeb web)
    at Microsoft.SharePoint.Publishing.PublishingWeb.MakeInheritanceChangeForAvailableWebTemplates(LroWssAreaPropertyPushdown lro, SPWeb webToChange, SPWeb parentWeb)
    at Microsoft.SharePoint.Publishing.PublishingWeb.InheritAvailableWebTemplates(Boolean useSynchronous, String successUrl, String failureUrl, OperationFinished finishOperation, Boolean throwExceptionOnFailure)
    at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaTemplateSettingsPage.SaveSiteTemplateSettings()
    at Microsoft.SharePoint.Publishing.Internal.CodeBehind.AreaTemplateSettingsPage.ButtonOkUpdatePageClick(Object sender, EventArgs e)
    at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
    at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Tried a lot. Please help on this.

    1. To be specific when we navigate to Site Actions–>Page Layouts and Site Templates, we were getting the error “Data at…”. To resolve that error i set “__Layouts” property to empty string using PowerShell. Now i can navigate to _Layouts/AreaTemplateSettings.aspx page. After hitting OK on this page i get above error “Object Ref …”

      1. You’ve fixed the page layout issue but not the site template issue. Honestly if you’re trying to do this manually one fix at a time you’re going to be in for quite a headache. There’s a reason why I built a command to do this – it’s a nightmare.

  168. Is the code available for SP2010? I would like to have separated some subsites which consists of site content type to individual site collection with separated DB. Any suggestions?

    Many thanks,

      1. Hi
        We are currently with sharepoint2010 Sp1 + Aug Cu. Can I use your tool for this build?
        By the way.. cna I know where can I download your Dll? Apprecitae your help.

  169. Hi Gary,
    Thanks for making this available. It is a great tool… saved my bacon today.
    FYI from my experience: We use a custom master page in the _catalogs/masterpage (Master Page Gallery) for sites and this resulted in a file not found error initially. Moving the master page over makes things better. I think this also caused the command to not complete.

    1. There must have been some odd issue with the migration of the gallery – the code does an export of the source _catalogs/masterpage gallery and then imports to the target – if that fails then obviously the masterpage won’t be there. (I use the content deployment API for this and there’s lots of issues with it that are beyond my control so it’s possible it just hit one of those issues).

  170. Hi Gary,
    This is a great post. Thanks a lot. I have a question regarding this. After the site is migrated into a new site collection any links (in content editor web parts and url fields of lists) that are pointing to different webs in the source site collection are broken. For e.g. I have a web http://myserver/sites/oldweb and I migrated it to http://myserver/sites/newsite where /sites/newsite is the new managed path. Any links that are in the web parts or url fields in the new site collection that are pointing to sites in the source site collection like http://myserver/sites/differentweb are being coverted to http://myserver/sites/newsite/sites/differentweb. So the server url including the new managed path is being appended to the link instead of just the server url. Is there any way to fix these links automatically?

    Hope I have explained the problem clearly.


    1. In some situations this does happen which is why I’ve created some of the replace commands that I have (there are commands for web part content, list items, and navigation – you can use them to fix the URLs (at least most of them)).

  171. Does it has any limitation on the size of the target sub-site? I am talking about a very larget sub-site which may be up to 50G

  172. Hi Gary,

    Is there anyway to change where the export files go? I would prefer to make them go somewhere else than on the c:\.


    1. It’s on my list to add a parameter to override where the temp files go (it’s just a very, very, very long list at this point and I have very, very, very limited time to tend to it).

  173. Thanks for sharing your work with us Gary.

    I’ve got a problem with the command below. The following error appears: Value cannot be null. Parameter name: String

    stsadm –o gl-convertsubsitetositecollection –sourceurl “http://moss-server:20585/sites/Maquette/” -targeturl “http://moss-server:20585/sites/Maquette/site” -createmanagedpath -nofilecompression -owneremail “” -ownerlogin “moss-server\mossadmin” -deletesource -verbose

    I’ve used the two commands above:
    1.Add-SPSolution Lapointe.SharePoint2010.Automation.wsp
    2.Install-SPSolution -Identity Lapointe.SharePoint2010.Automation.wsp -GACDeployment

    The DLL seems properly Gac’d :
    Name: lapointe.sharepoint2010.automation.wsp
    Type: Core Solution
    Contains Web Application Resource: No
    Contains Global Assembly: Yes
    Contains Code Access Security Policy: No
    Deployment Server Type: Front-end Web server
    Deployment Status: Deployed
    Deployed To: Globally deployed.
    Last Operation Result: The solution was successfully deployed.
    Last Operation Details: XXXX-XXX-XXX : The solution was successfully deployed.
    Last Operation Time: 6/15/2011 6:02 PM

    What are we doing wrong ?

    1. There’s probably some object somewhere that is null when my code is expecting it to not be. Best way to troubleshoot would be to download the source and build the debug build which should give you the stack trace with the error (I believe I have this command dumping the stack trace – most don’t but this one is particularly complex so I’m pretty sure it does).

  174. Hi Gary,

    I have one question to you. I downloaded and deployend the lapointe.sharepoint2010.automation.wsp
    solution on our moss farm (1. WFE and Index + 2. WFE) successfully. I wanted to convert the subsite to site on my enviroment but the process is hanging on “Reparing imported site” again. I did the stsadm -o execadmsvcjobs command manually without success. We found out that the process is waiting for the timer job but I couldn’t find the timer job for it on CA. First I did the other command “gl-repairsitecollectionimportedfromsubsite” with the same issue. The process was hanging with the output “End of fixing page layouts and site template”. I needed to kill the process after one day.

    Can you help my to resolve the problem but in my opinion always works fine but the completation of the process not and the process is waiting for something?

    Many thanks in advance.

    1. Are you on 2007 or 2010? If on 2010, use the PowerShell cmdlet and not the stsadm command – it’s easier :). I honestly don’t know why it is hanging for you – there is no timer job that my code executes or otherwise is waiting for so not sure what you’re referring to there.

  175. Gary, fantastic solution to a tricky problem! My issue right now is that the exported file goes to my c: drive, which is not large enough for the export. Can I change the drive that the file is saved to?

  176. Hi Gary,

    I tried the Powershell command (SP2010), but I’m running into an error. It seems to be doing a lot of things right because I end up with a site which seems to be working, but the command fails with the following error:

    ConvertTo-SPSite : A duplicate content type “System” was found.
    At line:1 char:17

    I have no idea if this is harmfull in any way or if there are now things missing which should have been done after this. Please advise 🙂

    1. After you get the error, type this and post the results. This will help me to see where the error is:
      $Error[0].Exception | select *

      All that said, this is one of the first steps so there’s still a lot to do – however, if the site is working for you then no worries right? (if the site is not a publishing site then most of what this guys is doing won’t get hit).

  177. Hi Garry,

    Is this still functional with MOSS 2007 or only with 2010 now? I just want to make sure before I install it and test it out. I’ve been looking for something to make this easy and still being on 2007 limits me somewhat.

    Another somewhat related question, could this be used to move an entire site collection from say a 2007 MOSS to a SP2010 farm as a migration tool? I am just curious if that would work.

    1. There’s a separate download for 2007 but yes, it should work. That said, I’ve moved on to 2010 and just don’t have time to address issues if you do see any. As for migration, no – you’d need a third party tool to go from 2007 to 2010 (or ootb upgrade).

  178. Hi Garry,

    I’d like to convert the web “subsite1” from the sitecollection “sc1” on the Web APP “” (“”) to the site collection “subsite1” in the same Web APP (“”). The configured managed paths in this Web APP are the default paths:

    – (root) ==> explicit inclusion
    – sites ==> wild card inclusion

    So I used the follwing command:
    stsadm -o gl-convertsubsitetositecollection -sourceurl “” -targeturl “” -owneremail -ownerlogin lab\WSAdministrator -ownername “WSAdministrator”

    But I got the following error information:

    “Exporting site…

    Site exported.

    Creating site for import…

    Site created.

    Importing site…
    The file cannot be imported because its parent web /sites/subsite1/subsite1 does not exist.”

    Why “/sites/subsite1/subsite1” and not “/sites/subsite1” ?

    I can access the new Site Collection under the URL “”, but i get the template selection page (there was no template created).

    What must I do to accomplish this?

    Many thanks in advance!

    1. Hi Gary,

      I tested this scenario with another site collection. Here it worked! May be that the first site collection was corrupted.

      But I have the problem that the security in the converted site collection is not set correctly (although I used the command option “-includeusersecurity”). The SharePoint-Groups and Permission Sets were imported but the permission sets were not associated to the Sharpoint-Groups at top-level site; so I had to do this manually.

      What must be done that the permission sets are associated to the SharePoint-Groups so it is in the source sub-site?

      Many thanks in advance!

  179. I forgot that I asked a question a little while back and know the answer now but I have another question.

    What is there out there (your extensions?) that will do Workflow migration? Do I need to pay for this or can they be moved somehow? The “gl-backup” and “gl-backupsites” commands are not working for me; I am getting an unknown error and I believe those will do workflows (I could be wrong but unable to test) and I know that the export commands do not. Is there something command or extension wise that will facilitate this?

  180. Gary,
    Are there any updated instructions on how to do this with the 2010 Powershell scripts Convert-SPSite, Repair-SPSite?
    Has Microsoft made this any easier with 2010? I used your tools with SP 2007 to do this and it seemed like there was a lot of cleanup that we battled with for several weeks after we had converted a site.

    Thanks in advance for you help.

    1. I just haven’t haven’t had time to document the cmdlets yet (though you’ll get some examples by displaying the help for the cmdlet). Unfortunately this hasn’t changed at all with 2010 all the same issues are still present and then some.

  181. Hi Gary
    I am trying to converting a subsite into a separate site collection using below command.

    stsadm –o gl-convertsubsitetositecollection –sourceurl “http://XXXX/testweb/” -targeturl “http://XXXX/YYYY/” -createmanagedpath -nofilecompression -owneremail “” -ownerlogin “domain\user” -deletesource

    But iam getting folloiwng error
    Value cannot be null.
    Parameter name: String

    I am using sharepoint 2010 SP1 + Aug CU. Appreciate your help.

  182. I am trying to utilize this tool and it is moving every part of a site except for the actual documents in the Share Documents Library. The folder structure is there, just no documents. Any one have any insight or suggestions? Thanks.

  183. Gary,
    Is there a way to recursively restore the subsite to a site collection and restore its subsites from the cmp file? I can successfully prmote/restore the top subsite to the root of a site collection but I loose its children

  184. Gary,
    I am trying to use your gl-convertsubsitetositecollection command to convert a MOSS site into its own site collection, but during the “Exporting site” step of the conversion I keep getting insufficient memory available errors. The site is ~30 GB and I’d like to convert even larger sites too. The server has both SharePoint and SQL Server installed on it (which I know is not good practice, but I did not configure this server) and has 12 GB of RAM.

    I’m pretty sure that the problem isn’t with your script, but with the environment, but I was wondering if you had any advice on how to get around this problem. Is there a less memory intensive way to export a large site?

  185. Gary,

    I’m migrating a subsite to a site collection, and after importing the subsite into the site collection, I’m running your command gl-repairsitecollectionimportedfromsubsite. After copying the content types, it displays an error and quits. I can’t figure out what the problem is, and debugging it is a bit beyond my abilities. Any ideas? Below are the last couple of lines that display before it fails:

    Progress: Creating content type ‘CreditRequestTemplate’…
    Progress: Setting fields for content type ‘CreditRequestTemplate’…
    Progress: Adding content type ‘CreditRequestTemplate’ to collection…
    Progress: Adding site columns for content type ‘CreditRequestTemplate’…
    Progess: End copying content types.
    Input string was not in a correct format.

  186. Hi Gary,
    When I run ConvertTo-SPSite I get:

    ConvertTo-SPSite : Could not find WebTemplate #75802 with LCID 1033.
    At line:1 char:17

    Here is the relevant excerpt from the logfile:

    [01/06/2012 08:39:58] Progress: Initializing Import.
    [01/06/2012 08:40:33] FatalError: Could not find WebTemplate #75802 with LCID 1033.
    [01/06/2012 08:40:33] Debug: at Microsoft.SharePoint.Deployment.ImportRequirementsManager.VerifyWebTemplate(SPRequirementObject reqObj)
    at Microsoft.SharePoint.Deployment.ImportRequirementsManager.DeserializeAndValidate()
    at Microsoft.SharePoint.Deployment.SPImport.VerifyRequirements()
    at Microsoft.SharePoint.Deployment.SPImport.Run()


  187. hey gary i am stuck at the “repairing imported site” using the gl-convertsubsitetositecollection is that normal ?

  188. Hi Gary, I am running into an issue with ConvertTo-SPSite. After a few trial and error runs with this command I was able to finally get it to run by logging onto the WFE as the Farm admin account and running SharePoint 2010 Management Shell as admin. Ok that bullet dodged… but after the sub site is promoted to a site collection something strange happens.

    URLs with in documents are updated… which is good if the the url is/was pointing to a spot within the sub-site it resides in. However, other links to sub-sites also get updated by adding the new site collection url.

    like this:

    Good: (subsite) hostheader/subsite/link (site collection) hostheader/sites/subsite/link

    BAD: (subsite) hostheader/Alternate/link (site Collection) hostheader/sites/subsite/alternate/link

    **Keep in mind this is a single document with inthe original (subsite) that is brought along for the ride during the promotion to a (site collection).

  189. What am I missing here? Where is the batch file I just read about for a page and a half? I see no link or download or redirect. I am looking for the batch file described in solution 2 that takes a subsite and converts it to a site collection and cleans everything up? Are these commands inherant to sharepoint or do I have to install something?

    1. The solutions are custom stsadm commands that you can download from the downloads page. For SharePoint 2010 they’ve been converted to cmdlets. (Both are part of larger packages that contain all of my commands/cmdlets).

  190. Hi Gary, got the solution loaded, but getting error Value cannot be null.
    Parameter name: String

    I dont have visual studio 2010 and have tried filling out all of the parameters with no luck. Any suggestions or could I get the debug build? Thanks!

  191. Okay this seems like a great solution but I am not sure which solution to download on your page. Can you point me to the code directly.

Comments are closed.