Cmdlets for Adobe Target

Build 25.0.9434

Establishing a Connection

With the CData Cmdlets users can install a data module, set the connection properties, and start scripting. This section provides examples of using our AdobeTarget Cmdlets with native PowerShell cmdlets, like the CSV import and export cmdlets.

Connecting to Adobe Target

To connect to Adobe Target, you must provide the Tenant property along with the required authentication parameters mentioned below. Note that while other connection properties can influence processing behavior, they do not affect the ability to connect.

To determine your Tenant name:

  1. Log in to Adobe Experience. The URL will look similar to: "https://experience.adobe.com/#/@mycompanyname/preferences/general-section".
  2. Extract the value after the "/#/@". In this example, it is "mycompanyname".
  3. Set the Tenant connection property to that value.

Authenticating to Adobe Target

Adobe Target uses the OAuth authentication standard. You can authenticate with the OAuth (Server-to-Server) integration.

User Accounts (OAuth)

You must set AuthScheme to OAuthClient for all user account flows.

Note: Adobe authentication via OAuth requires updating your token every two weeks.

All Applications

CData provides an embedded OAuth application that simplifies OAuth authentication. Alternatively, you can create a custom OAuth application. Review Creating a Custom OAuth App for more information.

Obtaining the OAuth Access Token

Set the following properties to connect:

  • OAuthClientId : Set to the client Id assigned when you registered your app.
  • OAuthClientSecret : Set to the client secret assigned when you registered your app.
  • CallbackURL : Set to the redirect URI defined when you registered your app. For example: https://localhost:3333

With these settings, the provider obtains an access token from Adobe Target, which it uses to request data. The OAuth values are stored in the location specified by OAuthSettingsLocation, ensuring they persist across connections.

Creating a Connection Object

You can then use the Connect-AdobeTarget cmdlet to create a connection object that can be passed to other cmdlets:

$conn = Connect-AdobeTarget -OAuthClientId 'myOauthClientId' -OauthClientSecret 'myOAuthClientSecret' -CallbackURL 'myCallbackURL'

Retrieving Data

The Select-AdobeTarget cmdlet provides a native PowerShell interface for retrieving data:

$results = Select-AdobeTarget -Connection $conn -Table "Activities" -Columns @("Id, Name") -Where "Name='TestActivity1'"
The Invoke-AdobeTarget cmdlet provides an SQL interface. This cmdlet can be used to execute an SQL query via the Query parameter.

Piping Cmdlet Output

The cmdlets return row objects to the pipeline one row at a time. The following line exports results to a CSV file:

Select-AdobeTarget -Connection $conn -Table Activities -Where "Name = 'TestActivity1'" | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myActivitiesData.csv -NoTypeInformation

You will notice that we piped the results from Select-AdobeTarget 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 object in the result set, and we do not necessarily want that information in our CSV file.

However, this makes it easy to pipe the output of one cmdlet to another. The following is an example of converting a result set to JSON:

 
PS C:\> $conn  = Connect-AdobeTarget -OAuthClientId 'myOauthClientId' -OauthClientSecret 'myOAuthClientSecret' -CallbackURL 'myCallbackURL'
PS C:\> $row = Select-AdobeTarget -Connection $conn -Table "Activities" -Columns (Id, Name) -Where "Name = 'TestActivity1'" | select -first 1
PS C:\> $row | ConvertTo-Json
{
  "Connection":  {

  },
  "Table":  "Activities",
  "Columns":  [

  ],
  "Id":  "MyId",
  "Name":  "MyName"
} 

Deleting Data

The following line deletes any records that match the criteria:

Select-AdobeTarget -Connection $conn -Table Activities -Where "Name = 'TestActivity1'" | Remove-AdobeTarget

Modifying Data

The cmdlets make data transformation easy as well as data cleansing. The following example loads data from a CSV file into Adobe Target, checking first whether a record already exists and needs to be updated instead of inserted.

Import-Csv -Path C:\MyActivitiesUpdates.csv | %{
  $record = Select-AdobeTarget -Connection $conn -Table Activities -Where ("Id = `'"+$_.Id+"`'")
  if($record){
    Update-AdobeTarget -Connection $conn -Table Activities -Columns @("Id","Name") -Values @($_.Id, $_.Name) -Where "Id  = `'$_.Id`'"
  }else{
    Add-AdobeTarget -Connection $conn -Table Activities -Columns @("Id","Name") -Values @($_.Id, $_.Name)
  }
}

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434