How to pipe SAP SuccessFactors LMS Data to CSV in PowerShell
The CData Cmdlets Module for SAP SuccessFactors LMS is a standard PowerShell module offering straightforward integration with SAP SuccessFactors LMS. Below, you will find examples of using our SAPSuccessFactorsLMS Cmdlets with native PowerShell cmdlets.
Creating a Connection to Your SAP SuccessFactors LMS Data
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.
$conn = Connect-SAPSuccessFactorsLMS -User "$User" -CompanyId "$CompanyId" -Url "$Url" -InitiateOAuth "$InitiateOAuth"
Selecting Data
Follow the steps below to retrieve data from the Items table and pipe the result into to a CSV file:
Select-SAPSuccessFactorsLMS -Connection $conn -Table Items | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myItemsData.csv -NoTypeInformation
You will notice that we piped the results from Select-SAPSuccessFactorsLMS into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.
The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.