Un esempio in PowerShell 1.1 di export di un sito SharePoint 2007 (WSS3 - MOSS) su file .cmp e relativo import in un altro sito
PowerShell
# export
# se non funge lanciare prima da linea di comando
# Set-ExecutionPolicy RemoteSigned
# eseguire con: powershell .\SgartSPExport.ps1

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 

$orgUrl = "http://sharepoint2007/sito";
$tmpFile = "D:\Progetti\SPMigration\SPMigration\bin\Debug\TmpFile"
$fileToExport = "D:\Progetti\SPMigration\SPMigration\bin\Debug\Export_Sgart"
write-host [System.IO.Path]::GetDirectoryName($fileToExport)

#prepare setting for export
$exportSettings = new-object Microsoft.SharePoint.Deployment.SPExportSettings
$exportSettings.LogFilePath = $tmpFile
$exportSettings.FileCompression = $true
$exportSettings.AutoGenerateDataFileName = $false
#$exportSettings.OverwriteExistingDataFile = $true
$exportSettings.BaseFileName = [System.IO.Path]::GetFileName($fileToImport)
$exportSettings.FileLocation = [System.IO.Path]::GetDirectoryName($fileToImport)
#$exportSettings.FileMaxSize = 25
$exportSettings.ExportMethod = [Microsoft.SharePoint.Deployment.SPExportMethodType]::ExportAll
$exportSettings.SiteUrl = $orgUrl
$exportSettings.IncludeSecurity = [Microsoft.SharePoint.Deployment.SPIncludeSecurity]::None
$exportSettings.IncludeVersions = [Microsoft.SharePoint.Deployment.SPIncludeVersions]::CurrentVersion
#$exportSettings.LogExportObjectsTable = $false
#$exportSettings.ExcludeDependencies
$exportSettings.CommandLineVerbose = $true
#$exportSettings.TestRun = $true

#object to export 
$obj2 = new-object Microsoft.SharePoint.Deployment.SPExportObject
$obj2.IncludeDescendants = [Microsoft.SharePoint.Deployment.SPIncludeDescendants]::All
$obj2.Url = $orgUrl + "/Lists/Ente"
$obj2.Type = [Microsoft.SharePoint.Deployment.SPDeploymentObjectType]::List

$obj1 = new-object Microsoft.SharePoint.Deployment.SPExportObject
$obj1.IncludeDescendants = [Microsoft.SharePoint.Deployment.SPIncludeDescendants]::All
$obj1.Url = $orgUrl + "/Lists/Protocollo"
$obj1.Type = [Microsoft.SharePoint.Deployment.SPDeploymentObjectType]::List

$exportSettings.ExportObjects.Add($obj2)
$exportSettings.ExportObjects.Add($obj1)

#execute export
$export = new-object Microsoft.SharePoint.Deployment.SPExport($exportSettings)
$export.Run()

PowerShell
# import
# se non funge lanciare prima da linea di comando
# Set-ExecutionPolicy RemoteSigned
# eseguire con: powershell .\SgartSPImport.ps1

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 

$fileToImport = "D:\Progetti\SPMigration\SPMigration\bin\Debug\Export_Sgart_.cmp"
$destUrl = "http://sharepoint2007/sitonuovo"
$destUrlWeb = "http://sharepoint2007/sitonuovo"

$importSettings = new-object Microsoft.SharePoint.Deployment.SPImportSettings
$importSettings.BaseFileName = [System.IO.Path]::GetFileName($fileToImport)
$importSettings.FileLocation = [System.IO.Path]::GetDirectoryName($fileToImport)
$importSettings.FileCompression = $true
$importSettings.SiteUrl = $destUrl
$importSettings.WebUrl = $destUrlWeb;
$importSettings.RetainObjectIdentity = $false;
$importSettings.IncludeSecurity = [Microsoft.SharePoint.Deployment.SPIncludeSecurity]::None;
$importSettings.UpdateVersions = [Microsoft.SharePoint.Deployment.SPUpdateVersions]::Overwrite;
$importSettings.UserInfoDateTime = [Microsoft.SharePoint.Deployment.SPImportUserInfoDateTimeOption]::ImportAll;
$importSettings.CommandLineVerbose = $true;

$import = new-object Microsoft.SharePoint.Deployment.SPImport($importSettings);
$import.Run();
E' possibile ottenere un risultato simile tramite il comando STSADM.exe.
Potrebbe interessarti anche: