Skip to content

Command Line Interface for Salesforce Data Loader: A PowerShell wrapper to easily use Scripted Data Loader via command line.

License

Notifications You must be signed in to change notification settings

ubraig/sf-dataloader-cli

Repository files navigation

Command Line Interface for Salesforce Data Loader

What is it?

A PowerShell module intended to simplify the usage of Scripted Data Loader.

Why would you need it?

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.

How does it look like?

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

Step 1: Authorize the Source Org

In this example we use the default org of your SFDX project:

$MySourceOrg = sfauth

Step 2: Authorize the Target Org

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 [email protected] -ConsoleInput -InstanceUrl https://test.salesforce.com

Step 3: Extract all Lead Records from Source Org

Simple example to extract all Leads to a default target file 'Lead.csv':

sfextract $MySourceOrg Lead "SELECT Id, FirstName, LastName, Company FROM Lead"

Step 4: Insert all Leads to Target Org

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

How to get it?

Prerequisites

Mandatory

Optionally

  • Salesforce CLI if you want to use the authentication methods provided by SFDX.

Download and Install SfDataloaderCli PowerShell Module

  • 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 file dataloader_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

Import the SfDataloaderCli module into your PowerShell session

  • Open a PowerShell console window.
  • Run Import-Module D:\sf-dataloader-cli-0.0.1-beta\dataloader\SfDataloaderCli.psd1.

Get Started!

See the Wiki Pages on how to get started.

About

Command Line Interface for Salesforce Data Loader: A PowerShell wrapper to easily use Scripted Data Loader via command line.

Topics

Resources

License

Stars

Watchers

Forks