We are proud to share our inclusion in the 2024 Gartner Magic Quadrant for Data Integration Tools. We believe this recognition reflects the differentiated business outcomes CData delivers to our customers.
Get the Report →How to pipe Salesforce Data Cloud Data to CSV in PowerShell
Use standard PowerShell cmdlets to access Salesforce Data Cloud tables.
The CData Cmdlets Module for Salesforce Data Cloud is a standard PowerShell module offering straightforward integration with Salesforce Data Cloud. Below, you will find examples of using our SalesforceDataCloud Cmdlets with native PowerShell cmdlets.
Creating a Connection to Your Salesforce Data Cloud Data
Salesforce Data Cloud supports authentication via the OAuth standard.
OAuth
Set AuthScheme to OAuth.
Desktop Applications
CData provides an embedded OAuth application that simplifies authentication at the desktop.
You can also authenticate from the desktop via a custom OAuth application, which you configure and register at the Salesforce Data Cloud console. For further information, see Creating a Custom OAuth App in the Help documentation.
Before you connect, set these properties:
- InitiateOAuth: GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- OAuthClientId (custom applications only): The Client ID assigned when you registered your custom OAuth application.
- OAuthClientSecret (custom applications only): The Client Secret assigned when you registered your custom OAuth application.
When you connect, the driver opens Salesforce Data Cloud's OAuth endpoint in your default browser. Log in and grant permissions to the application.
The driver then completes the OAuth process as follows:
- Extracts the access token from the callback URL.
- Obtains a new access token when the old one expires.
- Saves OAuth values in OAuthSettingsLocation so that they persist across connections.
For other OAuth methods, including Web Applications and Headless Machines, refer to the Help documentation.
$conn = Connect-SalesforceDataCloud
Selecting Data
Follow the steps below to retrieve data from the Account table and pipe the result into to a CSV file:
Select-SalesforceDataCloud -Connection $conn -Table Account | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myAccountData.csv -NoTypeInformation
You will notice that we piped the results from Select-SalesforceDataCloud 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.