Command line options

Oct 5, 2016 at 5:37 AM

Is there any way to run this from the command line? I would like to batch import multiple lists, libraries and versions, without having to manually run the GUI each time.
Oct 5, 2016 at 12:00 PM
This is best done using Powershell.

Example script below.
# Data Importer For SharePoint
# Scripted Import
# Ensure that you change the variables below prior to running the script

# Full path to your settings file
$pathtosettings = "\\vmware-host\Shared Folders\Projects\ProductDevelopment\ImportForSharePoint\WorkingArea\Examples\Office365_StaffFolders_Folders_Excel_Select.xml"
# Full path to where SPImportHelper.DLL is deployed
$pathtoassembly = "\\vmware-host\Shared Folders\Projects\ProductDevelopment\ImportForSharePoint\SourceCode\ImportForSharePoint\SPImportHelper\bin\Release";

# This loads the required assembliies
# You may need to change the path if DIFS is not installed in this location
[System.Reflection.Assembly]::LoadFile($pathtoassembly+"\SPImportHelper.dll") | Out-Null
[System.Reflection.Assembly]::LoadFile($pathtoassembly+"\Microsoft.SharePoint.Client.dll") | Out-Null
[System.Reflection.Assembly]::LoadFile($pathtoassembly+"\Microsoft.SharePoint.Client.Runtime.dll") | Out-Null

# We create a new import settings object using an existing settings file
$importsettings = [SPImportHelper.Settings.Utility]::LoadSettings($pathtosettings);

# We tell the user what source is being imported from
Write-Host "Source : Connection String : " $importsettings.Source.OleDbSourceDataSetSettings.ConnectionString

# We Create a new import object
$import = New-Object SPImportHelper.Import.DataSetImportToSharePoint($importsettings);

# Write tell the user that we are starting the import
Write-Host "Importing";

# We start the import

# Write tell the user that we have finished the import
Write-Host "Finished";
Oct 5, 2016 at 12:03 PM
If you had multiple imports to complete but the settings files was always pretty much the same then you could re-use.

For example if you had another spreadsheet to import you could add onto the end of the script.
$importsettings.Source.OleDbSourceDataSetSettings.ConnectionString = "blah blah"

# Import another sheet
Oct 7, 2016 at 4:30 AM

I have referenced SPImportHelper.dll in a c# project, and created a command line application to import the files I need.
Oct 11, 2016 at 3:53 PM
DIFs 2.2 includes DataSetImportToSharePoint_Console for import so progress can be logged back to console app.