A PowerShell module intended to simplify the usage of Scripted Data Loader.
The Salesforce Data Loader "as is" offers two ways of using it:
- Data Loader GUI mode offers only limited options to save configuration settings for repetitive tasks.
- Data Loader Scripting (a.k.a. "Scripted Data Loader") is quite complex to configure and rather unflexible for ad-hoc changes: It requires to write .xml configuration files with the details of the operation to be executed.
This module is intended to fill the gap: You can run Salesforce Data Loader from of the PowerShell command line (What is PowerShell?) for ad-hoc as well as for repetitive tasks:
- Provides a set of straightforward commands and easy-to-remember command aliases for all operations like EXTRACT, INSERT, UPDATE, UPSERT and (HARD) DELETE.
- Easy to choose between SOAP API or Bulk API in either serial or parallel mode. Allows to set the batch size via command line option.
- Auto-creates mapping files in many scenarios.
- Encapsulates the handling of Salesforce authentication, e.g.
- by generating key files and encrypting passwords, i.e. the "username + password + security token" style,
- optionally by using the authorization information as handled by the Salesforce SFDX CLI.
- Supports all PowerShell standard features like help pages, tab completion for parameters, approved verb best practices etc.
A very basic example to copy Leads from one Org to another in 4 simple steps. For more examples and command reference see the Wiki Pages
In this example we use the default org of your SFDX project:
$MySourceOrg = sfauth
In this example for a Sandbox org we will give the username and have the password and security token prompted via console input:
$MyTargetOrg = sfauth MyUserName@MyCompanyName.com -ConsoleInput -InstanceUrl https://test.salesforce.com
Simple example to extract all Leads to a default target file 'Lead.csv':
sfextract $MySourceOrg Lead "SELECT Id, FirstName, LastName, Company FROM Lead"
Simple example to import those Leads from the default source file 'Lead.csv' to another org. A default Data Loader mapping file (.sdl) ist automatically created on the fly from the column headers in the .csv file:
sfinsert $MyTargetOrg Lead
Mandatory
- Windows 10 or newer with PowerShell v5.1 or newer. NOTE: v5.1 is already installed by default on Windows 10 and newer. For further details see Installing Windows PowerShell
- A Java Runtime Environment (JRE) version 11 or later as described in Considerations for Installing Data Loader, e.g. Zulu OpenJDK. Make sure that the JAVA_HOME environment variable is set properly.
- A download of the latest Salesforce Data Loader .zip file from https://developer.salesforce.com/tools/data-loader or from https://github.com/forcedotcom/dataloader/releases. NOTE: There is no need to run the installation batch file from inside the .zip. This would only be needed if you also want to use Data Loader independently of the SfDataloaderCli module.
- Make sure, you have got the proper permissions in your Salesforce Org as described in Salesforce Data Loader Installation Considerations.
Optionally
- Salesforce CLI if you want to use the authentication methods provided by SFDX.
- Download the .zip file of the latest stable version from Releases.
- Extract the files to a target directory of your choice, e.g.
D:\sf-dataloader-cli-0.0.1-beta
- From the Data Loader .zip file (see prerequisites above), locate the Data Loader .jar file: e.g. in the
dataloader_v58.0.2.zip
this would be the filedataloader_v58.0.2.jar
. - Copy this .jar file to the corresponding directory in the PowerShell module directory, e.g. to
D:\sf-dataloader-cli-0.0.1-beta\dataloader
- Open a PowerShell console window.
- Run
Import-Module D:\sf-dataloader-cli-0.0.1-beta\dataloader\SfDataloaderCli.psd1
.
See the Wiki Pages on how to get started.