Ready to get started?

Learn more about the CData ADO.NET Provider for Salesforce Pardot or download a free trial:

Download Now

Automate Salesforce Pardot Integration Tasks from PowerShell

Are you looking for a quick and easy way to access Salesforce Pardot data from PowerShell? We show how to use the Cmdlets for Salesforce Pardot and the CData ADO.NET Provider for Salesforce Pardot to connect to Salesforce Pardot data and synchronize, automate, download, and more.

The CData Cmdlets for Salesforce Pardot are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Salesforce Pardot.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the Salesforce Pardot API, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Salesforce Pardot data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Salesforce Pardot. To access Salesforce Pardot data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Salesforce Pardot.

After obtaining the needed connection properties, accessing Salesforce Pardot data in PowerShell consists of three basic steps.

Salesforce Pardot supports connecting through API Version, Username, Password and User Key.

  • ApiVersion: The Salesforce Pardot API version which the provided account can access. Defaults to 4.
  • User: The Username of the Salesforce Pardot account.
  • Password: The Password of the Salesforce Pardot account.
  • UserKey: The unique User Key for the Salesforce Pardot account. This key does not expire.
  • IsDemoAccount (optional): Set to TRUE to connect to a demo account.

Accessing the Pardot User Key

The User Key of the current account may be accessed by going to Settings -> My Profile, under the API User Key row.

PowerShell

  1. Install the module:

    Install-Module SalesforcePardotCmdlets
  2. Connect:

    $salesforcepardot = Connect-SalesforcePardot -ApiVersion "$ApiVersion" -User "$User" -Password "$Password" -UserKey "$UserKey"
  3. Search for and retrieve data:

    $prospectaccountid = "703" $prospects = Select-SalesforcePardot -Connection $salesforcepardot -Table "Prospects" -Where "ProspectAccountId = `'$ProspectAccountId`'" $prospects

    You can also use the Invoke-SalesforcePardot cmdlet to execute SQL commands:

    $prospects = Invoke-SalesforcePardot -Connection $salesforcepardot -Query 'SELECT * FROM Prospects WHERE ProspectAccountId = @ProspectAccountId' -Params @{'@ProspectAccountId'='703'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Salesforce Pardot\lib\System.Data.CData.SalesforcePardot.dll")
  2. Connect to Salesforce Pardot:

    $conn= New-Object System.Data.CData.SalesforcePardot.SalesforcePardotConnection("ApiVersion=4;User=YourUsername;Password=YourPassword;UserKey=YourUserKey;") $conn.Open()
  3. Instantiate the SalesforcePardotDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Email from Prospects" $da= New-Object System.Data.CData.SalesforcePardot.SalesforcePardotDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.email }

Update Salesforce Pardot Data

PowerShell

Update-SalesforcePardot -Connection $SalesforcePardot -Columns @('Id','Email') -Values @('MyId', 'MyEmail') -Table Prospects -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.SalesforcePardot.SalesforcePardotCommand("UPDATE Prospects SET ProspectAccountId='703' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.SalesforcePardot.SalesforcePardotParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Salesforce Pardot Data

PowerShell

Add-SalesforcePardot -Connection $SalesforcePardot -Table Prospects -Columns @("Id", "Email") -Values @("MyId", "MyEmail")

ADO.NET

$cmd = New-Object System.Data.CData.SalesforcePardot.SalesforcePardotCommand("INSERT INTO Prospects (ProspectAccountId) VALUES (@myProspectAccountId)", $conn) $cmd.Parameters.Add(new System.Data.CData.SalesforcePardot.SalesforcePardotParameter("@myProspectAccountId","703")) $cmd.ExecuteNonQuery()

Delete Salesforce Pardot Data

PowerShell

Remove-SalesforcePardot -Connection $SalesforcePardot -Table "Prospects" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.SalesforcePardot.SalesforcePardotCommand("DELETE FROM Prospects WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.SalesforcePardot.SalesforcePardotParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()