![]() |
VOOZH | about |
The CData Cmdlets for QuickBooks Online 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 QuickBooks Online.
CData provides the easiest way to access and integrate live data from QuickBooks Online. Customers use CData connectivity to:
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.
The Cmdlets are not only a PowerShell interface to QuickBooks Online, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete QuickBooks Online data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for QuickBooks Online. To access QuickBooks Online data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for QuickBooks Online.
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.
Install the module:
Install-Module QuickBooksOnlineCmdlets
Connect:
$quickbooksonline = Connect-QBOnline -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$fullyqualifiedname = "Cook, Brian" $customers = Select-QBOnline -Connection $quickbooksonline -Table "Customers" -Where "FullyQualifiedName = `'$FullyQualifiedName`'" $customers
You can also use the Invoke-QBOnline cmdlet to execute SQL commands:
$customers = Invoke-QBOnline -Connection $quickbooksonline -Query 'SELECT * FROM Customers WHERE FullyQualifiedName = @FullyQualifiedName' -Params @{'@FullyQualifiedName'='Cook, Brian'}
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")
Connect to QuickBooks Online:
$conn= New-Object System.Data.CData.QuickBooksOnline.QuickBooksOnlineConnection("InitiateOAuth=GETANDREFRESH;")
$conn.Open()
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-QBOnline -Connection $QuickBooksOnline -Columns @('DisplayName','Balance') -Values @('MyDisplayName', 'MyBalance') -Table Customers -Id "MyId"
$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()
Add-QBOnline -Connection $QuickBooksOnline -Table Customers -Columns @("DisplayName", "Balance") -Values @("MyDisplayName", "MyBalance")
$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()
Remove-QBOnline -Connection $QuickBooksOnline -Table "Customers" -Id "MyId"
$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()
CodeProject
Download a free trial of the QuickBooks Online Data Provider to get started:
Download NowLearn more:
👁 QuickBooks Online IconComplete 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.