Export/Import Sub-Site with PowerShell

Thanks to Russ Ramirez’s SharePoint Blog for providing me with the answer I needed.  From his post, SPWeb move or clone in PowerShell, I was able to come up with the following script.

$moveFrom = https://WEBAPP1/sites/SITECOLLECTION/SITEA/SITEA1
$moveTo = https://WEBAPP2/sites/SITECOLLECTION/SITEB/SITEB1/SITEA1NEW
$backup = "E:\Backup\20120104_BACKUP.cmp"
$siteName = "SITE NAME"
$siteDesc = "SITE DESCRIPTION"
Get-SPWeb $moveFrom | Select-Object -Property WebTemplate, Configuration
# !! Based on the results of the Get-SPWeb, update the next line for Template (Concat WebTemplate + "#" + Configuration)
New-SPWeb -Url $moveTo -Template STS#0 -Name $siteName -Description $siteDesc
Export-SPWeb $moveFrom -Path $backup -IncludeVersions All -Verbose -CompressionSize 100000000
Import-SPWeb $moveTo -Path $backup -Force
Advertisements

One Response to Export/Import Sub-Site with PowerShell

  1. ester4press says:

    I just used this to correct the misplacement of a site internally and it worked great. Nice work!

Leave a Reply

Fill in your details below or click an icon to log in:

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

%d bloggers like this: