Automate Oracle Eloqua Integration Tasks from PowerShell

Ready to get started?

Download a free trial:

Download Now

Learn more:

Eloqua ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Eloqua marketing automation platform including Contacts, Campaigns, Emails, Activities, and more!



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

The CData Cmdlets for Oracle Eloqua 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 Oracle Eloqua.

Cmdlets or ADO.NET?

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

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

There are two authentication methods available for connecting to Oracle Eloqua: Login and OAuth. The Login method requires you to have the Company, User, and Password of the user.

If you do not have access to the username and password or do not wish to require them, you can use OAuth authentication. OAuth is better suited for allowing other users to access their own data. Using login credentials is better suited for accessing your own data.

PowerShell

  1. Install the module:

    Install-Module OracleEloquaCmdlets
  2. Connect:

    $oracleeloqua = Connect-OracleEloqua -User "$User" -Password "$Password" -Company "$Company"
  3. Search for and retrieve data:

    $shipcity = "New York" $campaign = Select-OracleEloqua -Connection $oracleeloqua -Table "Campaign" -Where "ShipCity = `'$ShipCity`'" $campaign

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

    $campaign = Invoke-OracleEloqua -Connection $oracleeloqua -Query 'SELECT * FROM Campaign WHERE ShipCity = @ShipCity' -Params @{'@ShipCity'='New York'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.OracleEloqua.OracleEloquaConnection("User=user;Password=password;Company=CData;") $conn.Open()
  3. Instantiate the OracleEloquaDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Name, ActualCost from Campaign" $da= New-Object System.Data.CData.OracleEloqua.OracleEloquaDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.name $_.actualcost }

Update Oracle Eloqua Data

PowerShell

Update-OracleEloqua -Connection $OracleEloqua -Columns @('Name','ActualCost') -Values @('MyName', 'MyActualCost') -Table Campaign -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.OracleEloqua.OracleEloquaCommand("UPDATE Campaign SET ShipCity='New York' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.OracleEloqua.OracleEloquaParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Oracle Eloqua Data

PowerShell

Add-OracleEloqua -Connection $OracleEloqua -Table Campaign -Columns @("Name", "ActualCost") -Values @("MyName", "MyActualCost")

ADO.NET

$cmd = New-Object System.Data.CData.OracleEloqua.OracleEloquaCommand("INSERT INTO Campaign (ShipCity) VALUES (@myShipCity)", $conn) $cmd.Parameters.Add(new System.Data.CData.OracleEloqua.OracleEloquaParameter("@myShipCity","New York")) $cmd.ExecuteNonQuery()

Delete Oracle Eloqua Data

PowerShell

Remove-OracleEloqua -Connection $OracleEloqua -Table "Campaign" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.OracleEloqua.OracleEloquaCommand("DELETE FROM Campaign WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.OracleEloqua.OracleEloquaParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()