Tag Archives: SPSite

Moving sites and subsites in SharePoint 2007 Portals

Moving sites and subsites within SharePoint 2007

There is a really cool way that you can move a sharepoint site up or down in your hierarchy.

Let’s say you created a sharepoint site your root level (ie http://intranet/website) and six months later you decide it really should be contained under your IT subsite (http://intranet/it/website). You can use the program STSADM to move a site from one location to another.

Steps to move a WSS subsite.

1. Create the new target URL (I created a blank site @ http://intranet/it/website)
2. Fire up the command line
3. CD \”Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN”
4. Export the old URL using the following Command:

stsadm -o export -url http://intranet/website -filename c:\test\backup.cmp

5. Import the file back into Sharepoint using the following command:

stsadm -o import -url http://intranet/it/website -filename c:\test\backup.cmp

That’s it! You have moved your website. You need to check user permissions especially if you are moving to a new subsite!

OTHER COOL STUFF: There is an option to -includeusersecurity while you do the export. You can also choose whether or not to pull all the revision history over with the doc libs or not…

For a full view of options for Export / Import, run the following commands to see all your options:

stsadm -o export

stsadm -o import

Ref : Rob Ashcroft’s

Delete All Old Versions from SharePoint 2010 Document Libraries

How many versions of a typical document do you need to keep?  5?  10?  100?
SharePoint content databases often get cluttered with redundant versions of the same documents.  In some cases, I’ve seen presentation libraries with less than 10 GB of active content, but hundreds of GBs of content due to gradual changes.
If you’re ready to clear out old versions, SharePoint 2010’s Management Shell makes it easy.  The script below will iterate through all lists and update them to keep only the last 2 copies.  It will also loop through and delete unneeded versions.

Get-SPWebApplication |  Get-SPSite -Limit All |  Get-SPWeb -Limit All |  ForEach-Object  { ForEach($list in $_.Lists) { If($list.EnableVersioning -eq $true) { $list.MajorVersionLimit = 2; $list.Update(); ForEach($item in$list.Items) { $item.URL; $item.SystemUpdate() } } } }

You can see that it…
  1. Loops through all web applications
  2. Loops through their site collections
  3. Loops through their webs
  4. Loops through their lists
  5. If versioning’s enabled, it sets the major version limit to 2
  6. In order to remove old versions, it needs to loop through each item and perform a system update

The script can be easily amended to deal with only specific site collections / libraries.  To keep a different number of versions, modify the MajorVersionLimit variable above.