Automate QuickBooks Online Integration Tasks from PowerShell

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

The CData ADO.NET Provider for QuickBooks 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 QuickBooks Online.

About QuickBooks Online Data Integration

CData provides the easiest way to access and integrate live data from QuickBooks Online. Customers use CData connectivity to:

  • Realize high-performance data reads thanks to push-down query optimization for complex operations like filters and aggregations.
  • Read, write, update, and delete QuickBooks Online data.
  • Run reports, download attachments, and send or void invoices directly from code using SQL stored procedures.
  • Connect securely using OAuth and modern cryptography, including TLS 1.2, SHA-256, and ECC.

Many users access live QuickBooks Online data from preferred analytics tools like Power BI and Excel, directly from databases with federated access, and use CData solutions to easily integrate QuickBooks Online data with automated workflows for business-to-business communications.

For more information on how customers are solving problems with CData's QuickBooks Online solutions, refer to our blog: https://www.cdata.com/blog/360-view-of-your-customers.


Getting Started


ADO.NET Provider

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

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

QuickBooks Online uses the OAuth authentication standard. OAuth requires the authenticating user to log in through the browser. To authenticate using OAuth, you can use the embedded OAuthClientId, OAuthClientSecret, and CallbackURL or you can obtain your own by registering an app with Intuit. Additionally, if you want to connect to sandbox data, set UseSandbox to true.

See the Getting Started chapter of the help documentation for a guide to using OAuth.

  1. Load the provider's assembly:

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

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

    $sql="SELECT DisplayName, Balance from Customers"
    
    $da= New-Object System.Data.CData.QuickBooksOnline.QuickBooksOnlineDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
        Write-Host $_.displayname $_.balance
    }

Update QuickBooks Online Data

$cmd =  New-Object System.Data.CData.QuickBooksOnline.QuickBooksOnlineCommand("UPDATE Customers SET FullyQualifiedName='Cook, Brian' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.QuickBooksOnline.QuickBooksOnlineParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert QuickBooks Online Data

$cmd =  New-Object System.Data.CData.QuickBooksOnline.QuickBooksOnlineCommand("INSERT INTO Customers (FullyQualifiedName) VALUES (@myFullyQualifiedName)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.QuickBooksOnline.QuickBooksOnlineParameter("@myFullyQualifiedName","Cook, Brian")))
$cmd.ExecuteNonQuery()

Delete QuickBooks Online Data

$cmd =  New-Object System.Data.CData.QuickBooksOnline.QuickBooksOnlineCommand("DELETE FROM Customers WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.QuickBooksOnline.QuickBooksOnlineParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

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

 Download Now

Learn more:

QuickBooks Online Icon QuickBooks Online ADO.NET Provider

Complete read-write access to QuickBooks Online enables developers to search (Customers, Transactions, Invoices, Sales Receipts, etc.), update items, edit customers, and more, from any .NET application.