Ready to get started?

Learn more about the CData ADO.NET Provider for Act-On or download a free trial:

Download Now

Automate Act-On Integration Tasks from PowerShell

Are you looking for a quick and easy way to access Act-On data from PowerShell? We show how to use the Cmdlets for Act-On and the CData ADO.NET Provider for Act-On to connect to Act-On data and synchronize, automate, download, 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.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the Act-On API, 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.

After obtaining the needed connection properties, accessing Act-On data in PowerShell consists of three basic 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 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 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 System.Data.CData.ActOn.ActOnParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()