Automate SAP SuccessFactors LMS Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access SAP SuccessFactors LMS data from PowerShell? This article demonstrates how to utilize the SAP SuccessFactors LMS Cmdlets for tasks like connecting to SAP SuccessFactors LMS data, automating operations, downloading data, and more.

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

  1. Install the module:

    Install-Module SAPSuccessFactorsLMSCmdlets
  2. Connect:

    $sapsuccessfactorslms = Connect-SAPSuccessFactorsLMS  -User "$User" -CompanyId "$CompanyId" -Url "$Url" -InitiateOAuth "$InitiateOAuth"
    
  3. 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

  1. 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")
        
  2. 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()
    
  3. 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
    }
      

Ready to get started?

Download a free trial of the SAP SuccessFactors LMS Data Provider to get started:

 Download Now

Learn more:

SAP SuccessFactors LMS Icon SAP SuccessFactors LMS ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with SAP SuccessFactors LMS.