Automate Asana Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Asana ADO.NET Provider

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



Are you looking for a quick and easy way to access Asana data from PowerShell? We show how to use the Cmdlets for Asana and the CData ADO.NET Provider for Asana to connect to Asana data and synchronize, automate, download, 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.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the Asana API, 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.

After obtaining the needed connection properties, accessing Asana data in PowerShell consists of three basic 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 }