Ready to get started?

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

 Download Now

Learn more:

Asana Icon Asana ADO.NET Provider

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

Automate Asana Integration Tasks from PowerShell



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

The CData Cmdlets for Asana are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Asana.

PowerShell Cmdlets or ADO.NET Provider?

The Cmdlets are not only a PowerShell interface to Asana, but also an SQL interface; this tutorial shows how to use both to retrieve Asana data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Asana. To access Asana data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Asana.

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

You can optionally set the following to refine the data returned from Asana.

  • WorkspaceId: Set this to the globally unique identifier (gid) associated with your Asana Workspace to only return projects from the specified workspace. To get your workspace id, navigate to https://app.asana.com/api/1.0/workspaces while logged into Asana. This displays a JSON object containing your workspace name and Id.
  • ProjectId: Set this to the globally unique identifier (gid) associated with your Asana Project to only return data mapped under the specified project. Project IDs can be found in the URL of your project's Overview page. This will be the numbers directly after /0/.

Connect Using OAuth Authentication

You must use OAuth to authenticate with Asana. OAuth requires the authenticating user to interact with Asana using the browser. See the "Getting Started" chapter of the help documentation for a guide to using OAuth.

PowerShell

  1. Install the module:

    Install-Module AsanaCmdlets
  2. Connect:

    $asana = Connect-Asana -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -CallbackURL "$CallbackURL"
  3. Search for and retrieve data:

    $archived = "true" $projects = Select-Asana -Connection $asana -Table "projects" -Where "Archived = `'$Archived`'" $projects

    You can also use the Invoke-Asana cmdlet to execute SQL commands:

    $projects = Invoke-Asana -Connection $asana -Query 'SELECT * FROM projects WHERE Archived = @Archived' -Params @{'@Archived'='true'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Asana.AsanaConnection("OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='http://localhost:33333';InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the AsanaDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, WorkspaceId from projects" $da= New-Object System.Data.CData.Asana.AsanaDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.workspaceid }