Automate X-Cart Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

X-Cart ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with X-Cart.

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

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

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing X-Cart data in PowerShell consists of three basic steps.

An API Key must be created for your XCart Installation. In order to obtain the API Key, you need to install and configure the REST API Module for your X-Cart installation.

  • Login to your X-Cart Installation. Click on My addons on the bottom of the left side-bar navigation panel.
  • Search for REST API Module. Install the Module.
  • After the module has been installed, you need to set it up.
    • Go to the Settings section for the REST API Module.
    • On the settings page specify the API Key (only read)
  • Set the ApiKey and Url to the connection property to connect to data.


  1. Install the module:

    Install-Module XCartCmdlets
  2. Connect:

    $xcart = Connect-XCart -Url "$Url" -ApiKey "$ApiKey"
  3. Search for and retrieve data:

    $language = "en" $profiles = Select-XCart -Connection $xcart -Table "PROFILES" -Where "Language = `'$Language`'" $profiles

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

    $profiles = Invoke-XCart -Connection $xcart -Query 'SELECT * FROM PROFILES WHERE Language = @Language' -Params @{'@Language'='en'}


  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for X-Cart\lib\System.Data.CData.XCart.dll")
  2. Connect to X-Cart:

    $conn= New-Object System.Data.CData.XCart.XCartConnection("Url=;ApiKey=MyApiKey;") $conn.Open()
  3. Instantiate the XCartDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT ProfileId, FirstName from PROFILES" $da= New-Object System.Data.CData.XCart.XCartDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.profileid $_.firstname }