Automate SAP HANA XS Advanced Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

SAP HANA XS Advanced ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with SAP HANA XS Advanced.

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

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

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing SAP HANA XS Advanced data in PowerShell consists of three basic steps.

SAP HANA XSA uses the OAuth authentication standard. Before connecting, it is necessary to establish an SAP HANA XSA OData Service. See the OAuth section in the Help documentation for a guide.


  1. Install the module:

    Install-Module SAPHanaXSACmdlets
  2. Connect:

    $saphanaxsa = Connect-SAPHanaXSA -OAuthClientID "$OAuthClientID" -OAuthClientSecret "$OAuthClientSecret" -URL "$URL" -CallbackURL "$CallbackURL"
  3. Search for and retrieve data:

    $ = "" $ = Select-SAPHanaXSA -Connection $saphanaxsa -Table "" -Where " = `'$`'" $

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

    $ = Invoke-SAPHanaXSA -Connection $saphanaxsa -Query 'SELECT * FROM WHERE = @' -Params @{'@'=''}


  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for SAP HANA XS Advanced\lib\System.Data.CData.SAPHanaXSA.dll")
  2. Connect to SAP HANA XS Advanced:

    $conn= New-Object System.Data.CData.SAPHanaXSA.SAPHanaXSAConnection("OAuthClientID=my-ouath-client-id;OAuthClientSecret=my-oauth-client-secret;URL=https://hxehost:51027/euro.xsodata;CallbackURL=http://localhost:33333;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the SAPHanaXSADataAdapter, execute an SQL query, and output the results:

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