Automate SAP SuccessFactors LMS Integration Tasks from PowerShell
The CData Cmdlets for SAP SuccessFactors LMS 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 SuccessFactors LMS.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to SAP SuccessFactors LMS, but also an SQL interface; this tutorial shows how to use both to retrieve SAP SuccessFactors LMS data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for SAP SuccessFactors LMS. To access SAP SuccessFactors LMS data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for SAP SuccessFactors LMS.
Once you have acquired the necessary connection properties, accessing SAP SuccessFactors LMS data in PowerShell can be enabled in three steps.
SAP SuccessFactors LMS uses OAuth authentication. Before connecting, you must configure an OAuth application tied to your SAP SuccessFactors LMS account.
To establish a connection, set the following properties:
- User: Your SAP SuccessFactors LMS username.
- CompanyId: Your SAP SuccessFactors company identifier.
- Url: The SAP SuccessFactors API URL (e.g., https://api4.successfactors.com).
- OAuthClientId: The client Id assigned when you registered your custom OAuth application.
- OAuthClientSecret: The client secret assigned when you registered your custom OAuth application.
See the Getting Started chapter of the help documentation for a guide to creating a custom OAuth app and using OAuth.
PowerShell
-
Install the module:
Install-Module SAPSuccessFactorsLMSCmdlets
-
Connect:
$sapsuccessfactorslms = Connect-SAPSuccessFactorsLMS -User "$User" -CompanyId "$CompanyId" -Url "$Url" -InitiateOAuth "$InitiateOAuth"
-
Search for and retrieve data:
$active = "true" $items = Select-SAPSuccessFactorsLMS -Connection $sapsuccessfactorslms -Table "Items" -Where "Active = `'$Active`'" $items
You can also use the Invoke-SAPSuccessFactorsLMS cmdlet to execute SQL commands:
$items = Invoke-SAPSuccessFactorsLMS -Connection $sapsuccessfactorslms -Query 'SELECT * FROM Items WHERE Active = @Active' -Params @{'@Active'='true'}
ADO.NET
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for SAP SuccessFactors LMS\lib\System.Data.CData.SAPSuccessFactorsLMS.dll") -
Connect to SAP SuccessFactors LMS:
$conn= New-Object System.Data.CData.SAPSuccessFactorsLMS.SAPSuccessFactorsLMSConnection("User=username;CompanyId=CompanyId;Url=https://api4.successfactors.com;InitiateOAuth=GETANDREFRESH;") $conn.Open() -
Instantiate the SAPSuccessFactorsLMSDataAdapter, execute an SQL query, and output the results:
$sql="SELECT ItemID, ItemTitle from Items" $da= New-Object System.Data.CData.SAPSuccessFactorsLMS.SAPSuccessFactorsLMSDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.itemid $_.itemtitle }