Microsoft Land

Export-SPWeb Import-SPWeb Copy SharePoint content using PowerShell

Posted on: April 12, 2012


$sourceWebUrl = $args[0]

$destWebUrl = $args[1]

$path = “c:\Sriram\Contents\”

$lists = @(“ideastream”, “Clients”)

foreach($list in $lists)

{

Write-Host (“Exporting ” + $sourceWebUrl + “/lists/” + $list)

export-spweb $sourceWebUrl -ItemUrl (“/lists/” + $list) -IncludeUserSecurity -IncludeVersions All -path ($path + $list + “.cmp”) -nologfile -force

“Exporting complete.”

Write-Host (“Importing ” + $destWebUrl + “/lists/” + $list)

import-spweb $destWebUrl -IncludeUserSecurity -path ($path + $list + “.cmp”) -nologfile

“Importing Complete”

}

$doclibs = @(“sitecollectionimages”)

foreach($doclib in $doclibs)

{

Write-Host (“Exporting ” + $sourceWebUrl + “/” + $doclib)

export-spweb $sourceWebUrl -ItemUrl (“/” + $doclib) -IncludeUserSecurity -IncludeVersions All -path ($path + $doclib + “.cmp”) -nologfile -force

“Exporting complete.”

Write-Host (“Importing ” + $destWebUrl + “/” + $doclib)

import-spweb $destWebUrl -IncludeUserSecurity -path ($path + $doclib + “.cmp”) -nologfile

“Importing Complete”

}

About these ads

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

My Tweets

Follow

Get every new post delivered to your Inbox.

Join 121 other followers

%d bloggers like this: