Automate Exact Online Integration Tasks from PowerShell

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

The CData ADO.NET Provider for Exact Online is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Exact Online.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Exact Online; this tutorial shows how to use the Provider to create, retrieve, update, and delete Exact Online data.

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

Exact Online uses the OAuth authentication standard. The InitiateOAuth connection property facilitates the OAuth flow -- by default, this is set to GETANDREFRESH. You can also use the embedded OAuth credentials or you can register an OAuth app with Exact to obtain your own. In addition to the OAuth values, provide the Region. If Division is not set, the default Division is determined.

See the "Getting Started" chapter of the help documentation for more information.

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.ExactOnline.ExactOnlineConnection("Region='United States';Division=5512;InitiateOAuth=GETANDREFRESH;")
    $conn.Open()
  3. Instantiate the ExactOnlineDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Name, CreditLinePurchase from Accounts"
    
    $da= New-Object System.Data.CData.ExactOnline.ExactOnlineDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
        Write-Host $_.name $_.creditlinepurchase
    }

Update Exact Online Data

$cmd =  New-Object System.Data.CData.ExactOnline.ExactOnlineCommand("UPDATE Accounts SET IsCompetitor='False' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ExactOnline.ExactOnlineParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert Exact Online Data

$cmd =  New-Object System.Data.CData.ExactOnline.ExactOnlineCommand("INSERT INTO Accounts (IsCompetitor) VALUES (@myIsCompetitor)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ExactOnline.ExactOnlineParameter("@myIsCompetitor","False")))
$cmd.ExecuteNonQuery()

Delete Exact Online Data

$cmd =  New-Object System.Data.CData.ExactOnline.ExactOnlineCommand("DELETE FROM Accounts WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ExactOnline.ExactOnlineParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

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

 Download Now

Learn more:

Exact Online Icon Exact Online ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Exact Online data including Contacts, Opportunities, Accounts, and more!