Agile/Scrum blog

Onderwerp: SPImport

Using the SPImport events to control SharePoint content import process

Prajeesh Prathap Door: Prajeesh Prathap,  18-09-2014
Onderwerp: SharePoint  PowerShell  SPImport  

The SPImport class in the Microsoft.SharePoint.Deployment namespace participates with other classes in the Deployment namespace to support importing, publishing, and migrating Windows SharePoint content, as well as supporting restore capabilities of content.

You can initiate an import operation by first initializing an instance of the Microsoft.SharePoint.Deployment.SPImportSettings class with the required import settings, and then passing the SPImportSettings object to the constructor of SPImport class; you then call the SPImport.Run method. The SPImport type exposes events that can be used to control the process of import. You can utilize the event model in PowerShell to register the events and then make use of this information to control the complete process of importing and exporting SharePoint content. Below is the PowerShell snippet to use the Error event and use the data to fail the execution process after an Import is performed.