Ready to get started?

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

Download Now

Automate SAP Concur Integration Tasks from PowerShell

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

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

Cmdlets or ADO.NET?

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

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

SAP Concur uses the OAuth 2 authentication standard. You will need to obtain the OAuthClientId and OAuthClientSecret by registering an app with SAP Concur. See the Getting Started section of the help documentation for an authentication guide.

PowerShell

  1. Install the module:

    Install-Module SAPConcurCmdlets
  2. Connect:

    $sapconcur = Connect-SAPConcur -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret"
  3. Search for and retrieve data:

    $id = "1668776136772254" $departments = Select-SAPConcur -Connection $sapconcur -Table "Departments" -Where "Id = `'$Id`'" $departments

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

    $departments = Invoke-SAPConcur -Connection $sapconcur -Query 'SELECT * FROM Departments WHERE Id = @Id' -Params @{'@Id'='1668776136772254'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.SAPConcur.SAPConcurConnection("OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the SAPConcurDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, OfficeId from Departments" $da= New-Object System.Data.CData.SAPConcur.SAPConcurDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.officeid }

Update SAP Concur Data

PowerShell

Update-SAPConcur -Connection $SAPConcur -Columns @('Id','OfficeId') -Values @('MyId', 'MyOfficeId') -Table Departments -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.SAPConcur.SAPConcurCommand("UPDATE Departments SET Id='1668776136772254' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.SAPConcur.SAPConcurParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert SAP Concur Data

PowerShell

Add-SAPConcur -Connection $SAPConcur -Table Departments -Columns @("Id", "OfficeId") -Values @("MyId", "MyOfficeId")

ADO.NET

$cmd = New-Object System.Data.CData.SAPConcur.SAPConcurCommand("INSERT INTO Departments (Id) VALUES (@myId)", $conn) $cmd.Parameters.Add(new System.Data.CData.SAPConcur.SAPConcurParameter("@myId","1668776136772254")) $cmd.ExecuteNonQuery()

Delete SAP Concur Data

PowerShell

Remove-SAPConcur -Connection $SAPConcur -Table "Departments" -Id "MyId"

ADO.NET

$cmd = New-Object System.Data.CData.SAPConcur.SAPConcurCommand("DELETE FROM Departments WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.SAPConcur.SAPConcurParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()