Automate QuickBooks POS Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

QuickBooks POS ADO.NET Provider

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



Are you looking for a quick and easy way to access QuickBooks POS data from PowerShell? We show how to use the Cmdlets for QuickBooks POS and the CData ADO.NET Provider for QuickBooks POS to connect to QuickBooks POS data and synchronize, automate, download, and more.

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

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing QuickBooks POS data in PowerShell consists of three basic steps.

When you are connecting to a local QuickBooks instance, you do not need to set any connection properties.

Requests are made to QuickBooks POS through the Remote Connector. The Remote Connector runs on the same machine as QuickBooks POS 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, you will need to authorize the Remote Connector with QuickBooks POS. See the "Getting Started" chapter of the help documentation for a guide.

PowerShell

  1. Install the module:

    Install-Module QuickBooksPOSCmdlets
  2. Connect:

    $quickbookspos = Connect-QBPOS
  3. Search for and retrieve data:

    $lastname = "Cook" $customers = Select-QBPOS -Connection $quickbookspos -Table "Customers" -Where "LastName = `'$LastName`'" $customers

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

    $customers = Invoke-QBPOS -Connection $quickbookspos -Query 'SELECT * FROM Customers WHERE LastName = @LastName' -Params @{'@LastName'='Cook'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.QuickBooksPOS.QuickBooksPOSConnection("") $conn.Open()
  3. Instantiate the QuickBooksPOSDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT ListId, AccountLimit from Customers" $da= New-Object System.Data.CData.QuickBooksPOS.QuickBooksPOSDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.listid $_.accountlimit }

Update QuickBooks POS Data

PowerShell

Update-QBPOS -Connection $QuickBooksPOS -Columns @('ListId','AccountLimit') -Values @('MyListId', 'MyAccountLimit') -Table Customers -Id "MyListId"

ADO.NET

$cmd = New-Object System.Data.CData.QuickBooksPOS.QuickBooksPOSCommand("UPDATE Customers SET LastName='Cook' WHERE ListId = @myListId", $conn) $cmd.Parameters.Add(new System.Data.CData.QuickBooksPOS.QuickBooksPOSParameter("@myListId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert QuickBooks POS Data

PowerShell

Add-QBPOS -Connection $QuickBooksPOS -Table Customers -Columns @("ListId", "AccountLimit") -Values @("MyListId", "MyAccountLimit")

ADO.NET

$cmd = New-Object System.Data.CData.QuickBooksPOS.QuickBooksPOSCommand("INSERT INTO Customers (LastName) VALUES (@myLastName)", $conn) $cmd.Parameters.Add(new System.Data.CData.QuickBooksPOS.QuickBooksPOSParameter("@myLastName","Cook")) $cmd.ExecuteNonQuery()

Delete QuickBooks POS Data

PowerShell

Remove-QBPOS -Connection $QuickBooksPOS -Table "Customers" -Id "MyListId"

ADO.NET

$cmd = New-Object System.Data.CData.QuickBooksPOS.QuickBooksPOSCommand("DELETE FROM Customers WHERE ListId=@myListId", $conn) $cmd.Parameters.Add(new System.Data.CData.QuickBooksPOS.QuickBooksPOSParameter("@myListId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()