Ready to get started?

Download a free trial of the Sage Cloud Accounting Data Provider to get started:

 Download Now

Learn more:

Sage Cloud Accounting Icon Sage Cloud Accounting ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Sage Cloud Accounting.

Automate Sage Cloud Accounting Integration Tasks from PowerShell

Are you in search of a quick and easy way to access Sage Cloud Accounting data from PowerShell? This article demonstrates how to utilize the Sage Cloud Accounting Cmdlets for tasks like connecting to Sage Cloud Accounting data, automating operations, downloading data, and more.

The CData Cmdlets for Sage Cloud Accounting 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 Sage Cloud Accounting.

PowerShell Cmdlets or ADO.NET Provider?

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

Once you have acquired the necessary connection properties, accessing Sage Cloud Accounting data in PowerShell can be enabled in three steps.

You can connect to Sage Business Cloud Accounting using the embedded OAuth connectivity. When you connect, the OAuth endpoint opens in your browser. Log in and grant permissions to complete the OAuth process. See the OAuth section in the online Help documentation for more information on other OAuth authentication flows.


  1. Install the module:

    Install-Module SageBCAccountingCmdlets
  2. Connect:

    $sagebcaccounting = Connect-SageBCAccounting
  3. Search for and retrieve data:

    $sent = "TRUE" $salesinvoices = Select-SageBCAccounting -Connection $sagebcaccounting -Table "SalesInvoices" -Where "sent = `'$sent`'" $salesinvoices

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

    $salesinvoices = Invoke-SageBCAccounting -Connection $sagebcaccounting -Query 'SELECT * FROM SalesInvoices WHERE sent = @sent' -Params @{'@sent'='TRUE'}


  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Sage Cloud Accounting\lib\System.Data.CData.SageBCAccounting.dll")
  2. Connect to Sage Cloud Accounting:

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

    $sql="SELECT contact_name, total_amount from SalesInvoices" $da= New-Object System.Data.CData.SageBCAccounting.SageBCAccountingDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.contact_name $_.total_amount }

Update Sage Cloud Accounting Data


Update-SageBCAccounting -Connection $SageBCAccounting -Columns @('contact_name','total_amount') -Values @('Mycontact_name', 'Mytotal_amount') -Table SalesInvoices -Id "MyId"


$cmd = New-Object System.Data.CData.SageBCAccounting.SageBCAccountingCommand("UPDATE SalesInvoices SET sent='TRUE' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SageBCAccounting.SageBCAccountingParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert Sage Cloud Accounting Data


Add-SageBCAccounting -Connection $SageBCAccounting -Table SalesInvoices -Columns @("contact_name", "total_amount") -Values @("Mycontact_name", "Mytotal_amount")


$cmd = New-Object System.Data.CData.SageBCAccounting.SageBCAccountingCommand("INSERT INTO SalesInvoices (sent) VALUES (@mysent)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SageBCAccounting.SageBCAccountingParameter("@mysent","TRUE"))) $cmd.ExecuteNonQuery()

Delete Sage Cloud Accounting Data


Remove-SageBCAccounting -Connection $SageBCAccounting -Table "SalesInvoices" -Id "MyId"


$cmd = New-Object System.Data.CData.SageBCAccounting.SageBCAccountingCommand("DELETE FROM SalesInvoices WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SageBCAccounting.SageBCAccountingParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()