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”
}