SPWeb move or clone in PowerShell


When you have to move or clone a web in SharePoint 2010, you can make use of the Export-SPWeb and Import-SPWeb cmdlets in the Management Shell. The semantic difference between a move and a clone is whether you delete the web you exported from. There are just 4 basic steps.
 
1) Determine template used to create the source web
 
Get-SPWeb <web root url> | Select-Object -Property WebTemplate, Configuration
 
Where: <web root url> is http://myportal/sub-web1/sub-web11 for example
 
The output will look like this:
 
WebTemplate                                                                                               Configuration
——————–                                                                                                ——————–
BLANKINTERNET                                                                                                   2
 
2) Create a new blank web at a new location using the template determined from 1)
 
New-SPWeb -Url <web root url> -Template <template name string> -Name <title of web> -Description <description text>
 
Example: New-SPWeb -Url http://myportal/sub-web2/sub-web21 -Template BLANKINTERNET#2 -Name “subweb21” -Description “New blank publishing site with workflow” 
 
3) Export existing web
 
Export-SPWeb <web root url> -Path C:\ExportImportData\<web name>WebExport.cmp -CompressionSize 100000000
 
Example: Export-SPWeb http://myportal/sub-web1/sub-web11 -Path C:\ExportImportData\WebExport.cmp -CompressionSize 100000000
 
4) Import the web just exported in 3) into new web created in 2)
 
Import-SPWeb <web root url> -Path C:\ExportImportData\WebExport.cmp -Force
 
Example: Import-SPWeb http://myportal/sub-web2/sub-web21 -Path C:\ExportImportData\WebExport.cmp -Force
Advertisements

About generation12

I am a SharePoint/.NET consultant in the twin cities.
This entry was posted in PowerShell, SharePoint 2010. Bookmark the permalink.

4 Responses to SPWeb move or clone in PowerShell

  1. sharepointdiva says:

    Thank you! That was exactly what I needed.

  2. Pingback: Export/Import Sub-Site with PowerShell « SharePoint Diva

  3. Guru Marathe says:

    does this import all the documents which are in draft and pending status? i think we need to use -Includevesion all to do that.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s