Ready to get started?

Download a free trial of the Act-On Data Provider to get started:

 Download Now

Learn more:

Act-On Icon Act-On ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Act-On marketing automation data including Campaigns, Programs, Reports, and more!

Automate Act-On Integration Tasks from PowerShell



Are you in search of a quick and easy way to access Act-On data from PowerShell? This article demonstrates how to utilize the Act-On Cmdlets for tasks like connecting to Act-On data, automating operations, downloading data, and more.

The CData Cmdlets for Act-On 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 Act-On.

PowerShell Cmdlets or ADO.NET Provider?

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

Once you have acquired the necessary connection properties, accessing Act-On data in PowerShell can be enabled in three steps.

ActOn uses the OAuth authentication standard. To authenticate using OAuth, you will need to create an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties.

See the Getting Started guide in the CData driver documentation for more information.

PowerShell

  1. Install the module:

    Install-Module ActOnCmdlets
  2. Connect:

    $acton = Connect-ActOn
  3. Search for and retrieve data:

    $foldername = "New Folder" $images = Select-ActOn -Connection $acton -Table "Images" -Where "FolderName = `'$FolderName`'" $images

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

    $images = Invoke-ActOn -Connection $acton -Query 'SELECT * FROM Images WHERE FolderName = @FolderName' -Params @{'@FolderName'='New Folder'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Act-On\lib\System.Data.CData.ActOn.dll")
  2. Connect to Act-On:

    $conn= New-Object System.Data.CData.ActOn.ActOnConnection("InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the ActOnDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Name from Images" $da= New-Object System.Data.CData.ActOn.ActOnDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.name }

Update Act-On Data

PowerShell

Update-ActOn -Connection $ActOn -Columns @('Id','Name') -Values @('MyId', 'MyName') -Table Images -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.ActOn.ActOnCommand("UPDATE Images SET FolderName='New Folder' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ActOn.ActOnParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Act-On Data

PowerShell

Add-ActOn -Connection $ActOn -Table Images -Columns @("Id", "Name") -Values @("MyId", "MyName")

ADO.NET

$cmd = New-Object System.Data.CData.ActOn.ActOnCommand("INSERT INTO Images (FolderName) VALUES (@myFolderName)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ActOn.ActOnParameter("@myFolderName","New Folder"))) $cmd.ExecuteNonQuery()

Delete Act-On Data

PowerShell

Remove-ActOn -Connection $ActOn -Table "Images" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.ActOn.ActOnCommand("DELETE FROM Images WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ActOn.ActOnParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()