Automate Sage 200 Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Sage 200 ADO.NET Provider

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

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

The CData Cmdlets for Sage 200 are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Sage 200.

Cmdlets or ADO.NET?

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

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

  • Schema: Determines which Sage 200 edition you are connecting to. Specify either StandardUK or ProfessionalUK.
  • Subscription Key: Provides access to the APIs that are used to establish a connection. You will first need to log into the Sage 200 API website and subscribe to the API edition that matches your account. You can do so here: Afterwards, the subscription key may be found in your profile after logging into Sage 200.


  1. Install the module:

    Install-Module Sage200Cmdlets
  2. Connect:

    $sage200 = Connect-Sage200 -SubscriptionKey "$SubscriptionKey" -Schema "$Schema"
  3. Search for and retrieve data:

    $code = "12345" $banks = Select-Sage200 -Connection $sage200 -Table "Banks" -Where "Code = `'$Code`'" $banks

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

    $banks = Invoke-Sage200 -Connection $sage200 -Query 'SELECT * FROM Banks WHERE Code = @Code' -Params @{'@Code'='12345'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Sage200.Sage200Connection("SubscriptionKey=12345;Schema=StandardUK;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the Sage200DataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Code from Banks" $da= New-Object System.Data.CData.Sage200.Sage200DataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $ $_.code }