Automate Anaplan Integration Tasks from PowerShell

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

The CData ADO.NET Provider for Anaplan is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Anaplan.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for Anaplan; this tutorial shows how to use the Provider to retrieve Anaplan data.

Once you have acquired the necessary connection properties, accessing Anaplan data in PowerShell can be enabled in three steps.

Authenticating to Anaplan

The driver supports authenticating with Basic, Certificate, or OAuth. In every case, set Region to the region where your Anaplan account data is hosted (e.g., US1, which is the default).

Using Basic Authentication

Set AuthScheme to Basic, then supply your Anaplan User and Password. If your workspace uses single sign-on (SSO), you must be assigned as an Exception User to use Basic authentication.

Using Certificate Authentication

Set AuthScheme to Certificate, then supply the Certificate, CertificateType, and PrivateKey properties (and the matching CertificatePassword / PrivateKeyPassword if either is encrypted). The certificate must be a CA-issued X.509 certificate registered with your Anaplan tenant administrator.

Using OAuth Authentication

Register a custom OAuth application in Anaplan, then set the following properties:

  • OAuthClientId: The client Id assigned when you registered your custom OAuth application.
  • OAuthClientSecret: The client secret assigned when you registered your custom OAuth application.
  • CallbackURL: The redirect URI defined when you registered your application.
  • InitiateOAuth: Set to GETANDREFRESH to have the driver manage the OAuth token exchange and refresh automatically.

See the Getting Started chapter of the help documentation for a guide to creating a custom OAuth app and using OAuth.

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Anaplan\lib\System.Data.CData.Anaplan.dll")
        
  2. Connect to Anaplan:

     
    $conn= New-Object System.Data.CData.Anaplan.AnaplanConnection("OAuthClientId=your_client_id;OAuthClientSecret=your_client_secret;CallbackURL=your_callback_url;Region=US1;InitiateOAuth=GETANDREFRESH;")
    $conn.Open()
    
  3. Instantiate the AnaplanDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Region, Product from Sales"
    
    $da= New-Object System.Data.CData.Anaplan.AnaplanDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
    	Write-Host $_.region $_.product
    }
      

Ready to get started?

Download a free trial of the Anaplan Data Provider to get started:

 Download Now

Learn more:

Anaplan Icon Anaplan ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Anaplan.