![]() |
VOOZH | about |
The CData Cmdlets for QuickBooks 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.
CData simplifies access and integration of live QuickBooks data. Our customers leverage CData connectivity to:
Customers regularly integrate their QuickBooks data with preferred tools, like Power BI, Tableau, or Excel, and integrate QuickBooks data into their database or data warehouse.
The Cmdlets are not only a PowerShell interface to QuickBooks, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete QuickBooks data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for QuickBooks. To access QuickBooks data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for QuickBooks.
Once you have acquired the necessary connection properties, accessing QuickBooks data in PowerShell can be enabled in three steps.
When you are connecting to a local QuickBooks instance, you do not need to set any connection properties.
Requests are made to QuickBooks through the Remote Connector. The Remote Connector runs on the same machine as QuickBooks and accepts connections through a lightweight, embedded Web server. The server supports SSL/TLS, enabling users to connect securely from remote machines.
The first time you connect, authorize the Remote Connector with QuickBooks. See the "Getting Started" chapter of the help documentation for a guide.
Install the module:
Install-Module QuickBooksCmdlets
Connect:
$quickbooks = Connect-QB -URL "$URL" -User "$User" -Password "$Password"
Search for and retrieve data:
$type = "Commercial" $customers = Select-QB -Connection $quickbooks -Table "Customers" -Where "Type = `'$Type`'" $customers
You can also use the Invoke-QB cmdlet to execute SQL commands:
$customers = Invoke-QB -Connection $quickbooks -Query 'SELECT * FROM Customers WHERE Type = @Type' -Params @{'@Type'='Commercial'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for QuickBooks\lib\System.Data.CData.QuickBooks.dll")
Connect to QuickBooks:
$conn= New-Object System.Data.CData.QuickBooks.QuickBooksConnection("URL=http://remotehost:8166;User=admin;Password=admin123;")
$conn.Open()
Instantiate the QuickBooksDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Name, CustomerBalance from Customers"
$da= New-Object System.Data.CData.QuickBooks.QuickBooksDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.name $_.customerbalance
}
Update-QB -Connection $QuickBooks -Columns @('Name','CustomerBalance') -Values @('MyName', 'MyCustomerBalance') -Table Customers -Id "MyId"
$cmd = New-Object System.Data.CData.QuickBooks.QuickBooksCommand("UPDATE Customers SET Type='Commercial' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.QuickBooks.QuickBooksParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Add-QB -Connection $QuickBooks -Table Customers -Columns @("Name", "CustomerBalance") -Values @("MyName", "MyCustomerBalance")
$cmd = New-Object System.Data.CData.QuickBooks.QuickBooksCommand("INSERT INTO Customers (Type) VALUES (@myType)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.QuickBooks.QuickBooksParameter("@myType","Commercial")))
$cmd.ExecuteNonQuery()
Remove-QB -Connection $QuickBooks -Table "Customers" -Id "MyId"
$cmd = New-Object System.Data.CData.QuickBooks.QuickBooksCommand("DELETE FROM Customers WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.QuickBooks.QuickBooksParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the QuickBooks Data Provider to get started:
Download NowLearn more:
👁 QuickBooks IconComplete read-write access to QuickBooks enables developers to search (Customers, Transactions, Invoices, Sales Receipts, etc.), update items, edit customers, and more, from any .NET application.