Ready to get started?

Download a free trial of the ActiveCampaign Data Provider to get started:

 Download Now

Learn more:

ActiveCampaign Icon ActiveCampaign ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with ActiveCampaign account data including Accounts, Contacts, Deals, and more!

Automate ActiveCampaign Integration Tasks from PowerShell

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

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

PowerShell Cmdlets or ADO.NET Provider?

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

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

ActiveCampaign supports authenticating with the API Key. To connect to ActiveCampaign, set the following:

  • URL: This can be found in your account on the My Settings page under the Developer tab. For example: https://{yourAccountName}
  • APIKey: This can be found in your account on the Settings page under the Developer tab. Each user in your ActiveCampaign account has their own unique API key.


  1. Install the module:

    Install-Module ActiveCampaignCmdlets
  2. Connect:

    $activecampaign = Connect-ActiveCampaign -URL "$URL" -APIKey "$APIKey"
  3. Search for and retrieve data:

    $lastname = "Smith" $contacts = Select-ActiveCampaign -Connection $activecampaign -Table "Contacts" -Where "LastName = `'$LastName`'" $contacts

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

    $contacts = Invoke-ActiveCampaign -Connection $activecampaign -Query 'SELECT * FROM Contacts WHERE LastName = @LastName' -Params @{'@LastName'='Smith'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.ActiveCampaign.ActiveCampaignConnection("URL=yourUrl;APIKey=yourApiKey") $conn.Open()
  3. Instantiate the ActiveCampaignDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT LastName, Email from Contacts" $da= New-Object System.Data.CData.ActiveCampaign.ActiveCampaignDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.lastname $ }

Update ActiveCampaign Data


Update-ActiveCampaign -Connection $ActiveCampaign -Columns @('LastName','Email') -Values @('MyLastName', 'MyEmail') -Table Contacts -Id "MyId"


$cmd = New-Object System.Data.CData.ActiveCampaign.ActiveCampaignCommand("UPDATE Contacts SET LastName='Smith' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ActiveCampaign.ActiveCampaignParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert ActiveCampaign Data


Add-ActiveCampaign -Connection $ActiveCampaign -Table Contacts -Columns @("LastName", "Email") -Values @("MyLastName", "MyEmail")


$cmd = New-Object System.Data.CData.ActiveCampaign.ActiveCampaignCommand("INSERT INTO Contacts (LastName) VALUES (@myLastName)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ActiveCampaign.ActiveCampaignParameter("@myLastName","Smith"))) $cmd.ExecuteNonQuery()

Delete ActiveCampaign Data


Remove-ActiveCampaign -Connection $ActiveCampaign -Table "Contacts" -Id "MyId"


$cmd = New-Object System.Data.CData.ActiveCampaign.ActiveCampaignCommand("DELETE FROM Contacts WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.ActiveCampaign.ActiveCampaignParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()