Share via


PowerShell to export/import content of SharePoint site

 
The below command will Export the content of SharePoint site to the specified folder .It contains a Manifest.xml file which will be used to while importing the content to the site

 [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  
 $SPExport = New-Object Microsoft.SharePoint.Deployment.SPExport           
 $SPExportSettings = $SPExport.Settings           
 $SPExportSettings.SiteUrl= "http://win-ld2oc4jh6eb:111/"           
 $SPExportSettings.BaseFilename = "Manifest.xml"
 $SPExportSettings.FileCompression = $false          
 $SPExportSettings.FileLocation = "C:\SiteExport1"           
 $SPExportSettings.CommandLineVerbose = $true          
 $SPExportSettings.ExportMethod = [Microsoft.SharePoint.Deployment.SPExportMethodType]"ExportAll"          
 $SPExportSettings.LogFilePath ="C:\SiteExport1\logExport.log"          
 $SPExport.Run() 

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$importSettings = New-Object Microsoft.SharePoint.Deployment.SPImportSettings
$importSettings.SiteUrl= "http://win-ld2oc4jh6eb:222/"           
$importSettings.FileCompression = $false        
$importSettings.FileLocation = "C:\SiteExport1";
$importSettings.BaseFileName = "Manifest.xml";
$importSettings.RetainObjectIdentity = $false        
$importSettings.CommandLineVerbose = $true       
 $importSettings.LogFilePath ="C:\SiteExport1\logImport.log"
$import = New-Object Microsoft.SharePoint.Deployment.SPImport($importSettings)
$import.Run()