Ready to get started?

Download a free trial of the SAP Business One Data Provider to get started:

 Download Now

Learn more:

SAP Business One Icon SAP Business One ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with SAP Business One data including Accounts, Activities, Orders, Customers, and more!

Automate SAP Business One Integration Tasks from PowerShell

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

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

PowerShell Cmdlets or ADO.NET Provider?

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

Once you have acquired the necessary connection properties, accessing SAP Business One data in PowerShell can be enabled in three steps.

To authenticate to SAP Business One you must provide the Userand Passwordproperties.

To connect to data, specify Url. This is your SAP Business One Service Layer root URL.


  1. Install the module:

    Install-Module SAPBusinessOneCmdlets
  2. Connect:

    $sapbusinessone = Connect-SAPBusinessOne -Url "$Url" -User "$User" -Password "$Password" -CompanyDB "$CompanyDB"
  3. Search for and retrieve data:

    $doctype = "dDocument_Items" $orders = Select-SAPBusinessOne -Connection $sapbusinessone -Table "Orders" -Where "DocType = `'$DocType`'" $orders

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

    $orders = Invoke-SAPBusinessOne -Connection $sapbusinessone -Query 'SELECT * FROM Orders WHERE DocType = @DocType' -Params @{'@DocType'='dDocument_Items'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.SAPBusinessOne.SAPBusinessOneConnection("Url=http://localhost:50000/b1s/v1;User=username;Password=password;CompanyDB=dbname;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the SAPBusinessOneDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT DocEntry, DocType from Orders" $da= New-Object System.Data.CData.SAPBusinessOne.SAPBusinessOneDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.docentry $_.doctype }

Update SAP Business One Data


Update-SAPBusinessOne -Connection $SAPBusinessOne -Columns @('DocEntry','DocType') -Values @('MyDocEntry', 'MyDocType') -Table Orders -Id "MyId"


$cmd = New-Object System.Data.CData.SAPBusinessOne.SAPBusinessOneCommand("UPDATE Orders SET DocType='dDocument_Items' WHERE Id = @myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SAPBusinessOne.SAPBusinessOneParameter("@myId","10456255-0015501366"))) $cmd.ExecuteNonQuery()

Insert SAP Business One Data


Add-SAPBusinessOne -Connection $SAPBusinessOne -Table Orders -Columns @("DocEntry", "DocType") -Values @("MyDocEntry", "MyDocType")


$cmd = New-Object System.Data.CData.SAPBusinessOne.SAPBusinessOneCommand("INSERT INTO Orders (DocType) VALUES (@myDocType)", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SAPBusinessOne.SAPBusinessOneParameter("@myDocType","dDocument_Items"))) $cmd.ExecuteNonQuery()

Delete SAP Business One Data


Remove-SAPBusinessOne -Connection $SAPBusinessOne -Table "Orders" -Id "MyId"


$cmd = New-Object System.Data.CData.SAPBusinessOne.SAPBusinessOneCommand("DELETE FROM Orders WHERE Id=@myId", $conn) $cmd.Parameters.Add((New-Object System.Data.CData.SAPBusinessOne.SAPBusinessOneParameter("@myId","001d000000YBRseAAH"))) $cmd.ExecuteNonQuery()