![]() |
VOOZH | about |
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.
The Cmdlets are not only a PowerShell interface to Salesforce Pardot, 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.
Once you have acquired the necessary connection properties, accessing Salesforce Pardot data in PowerShell can be enabled in three steps.
Salesforce Pardot supports connecting through API Version, Username, Password and User Key.
The User Key of the current account may be accessed by going to Settings -> My Profile, under the API User Key row.
Install the module:
Install-Module SalesforcePardotCmdlets
Connect:
$salesforcepardot = Connect-SalesforcePardot -ApiVersion "$ApiVersion" -User "$User" -Password "$Password" -UserKey "$UserKey"
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'}
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")
Connect to Salesforce Pardot:
$conn= New-Object System.Data.CData.SalesforcePardot.SalesforcePardotConnection("ApiVersion=4;User=YourUsername;Password=YourPassword;UserKey=YourUserKey;")
$conn.Open()
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-SalesforcePardot -Connection $SalesforcePardot -Columns @('Id','Email') -Values @('MyId', 'MyEmail') -Table Prospects -Id "MyId"
$cmd = New-Object System.Data.CData.SalesforcePardot.SalesforcePardotCommand("UPDATE Prospects SET ProspectAccountId='703' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SalesforcePardot.SalesforcePardotParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-SalesforcePardot -Connection $SalesforcePardot -Table Prospects -Columns @("Id", "Email") -Values @("MyId", "MyEmail")
$cmd = New-Object System.Data.CData.SalesforcePardot.SalesforcePardotCommand("INSERT INTO Prospects (ProspectAccountId) VALUES (@myProspectAccountId)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SalesforcePardot.SalesforcePardotParameter("@myProspectAccountId","703")))
$cmd.ExecuteNonQuery()
Remove-SalesforcePardot -Connection $SalesforcePardot -Table "Prospects" -Id "MyId"
$cmd = New-Object System.Data.CData.SalesforcePardot.SalesforcePardotCommand("DELETE FROM Prospects WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SalesforcePardot.SalesforcePardotParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Salesforce Pardot Data Provider to get started:
Download NowLearn more:
👁 Salesforce Pardot IconRapidly create and deploy powerful .NET applications that integrate with Salesforce Pardot.