Ready to get started?

Learn more about the CData ADO.NET Provider for SAP ERP or download a free trial:

Download Now

Automate SAP Integration Tasks from PowerShell

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

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

Cmdlets or ADO.NET?

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

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

You can connect to SAP systems using either librfc32.dll, librfc32u.dll, NetWeaver, or Web Services (SOAP). Set the ConnectionType connection property to CLASSIC (librfc32.dll), CLASSIC_UNICODE (librfc32u.dll), NETWEAVER, or SOAP.

If you are using the SOAP interface, set the Client, RFCUrl, SystemNumber, User, and Password properties, under the Authentication section.

Otherwise, set Host, User, Password, Client, and SystemNumber.

Note: We do not distribute the librfc32.dll or other SAP assemblies. You must find them from your SAP installation and install them on your machine.

For more information, see this guide on obtaining the connection properties needed to connect to any SAP system.


  1. Install the module:

    Install-Module SAPERPCmdlets
  2. Connect:

    $saperp = Connect-SAPERP -Host "$Host" -User "$User" -Password "$Password" -Client "$Client" -System Number "$System Number" -ConnectionType "$ConnectionType" -Location "$Location"
  3. Search for and retrieve data:

    $ernam = "BEHRMANN" $mara = Select-SAPERP -Connection $saperp -Table "MARA" -Where "ERNAM = `'$ERNAM`'" $mara

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

    $mara = Invoke-SAPERP -Connection $saperp -Query 'SELECT * FROM MARA WHERE ERNAM = @ERNAM' -Params @{'@ERNAM'='BEHRMANN'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.SAPERP.SAPERPConnection(";User=EXT90033;Password=xxx;Client=800;System Number=09;ConnectionType=Classic;Location=C:\\mysapschemafolder;") $conn.Open()
  3. Instantiate the SAPERPDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT MANDT, MBRSH from MARA" $da= New-Object System.Data.CData.SAPERP.SAPERPDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.mandt $_.mbrsh }