Ready to get started?

Learn more about the CData ADO.NET Provider for Airtable or download a free trial:

Download Now

Automate Airtable Integration Tasks from PowerShell

Are you looking for a quick and easy way to access Airtable data from PowerShell? We show how to use the Cmdlets for Airtable and the CData ADO.NET Provider for Airtable to connect to Airtable data and synchronize, automate, download, and more.

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

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing Airtable data in PowerShell consists of three basic steps.

APIKey, BaseId and TableNames parameters are required to connect to Airtable. ViewNames is an optional parameter where views of the tables may be specified.

  • APIKey : API Key of your account. To obtain this value, after logging in go to Account. In API section click Generate API key.
  • BaseId : Id of your base. To obtain this value, it is in the same section as the APIKey. Click on Airtable API, or navigate to https://airtable.com/api and select a base. In the introduction section you can find "The ID of this base is appxxN2ftedc0nEG7."
  • TableNames : A comma separated list of table names for the selected base. These are the same names of tables as found in the UI.
  • ViewNames : A comma separated list of views in the format of (table.view) names. These are the same names of the views as found in the UI.

PowerShell

  1. Install the module:

    Install-Module AirtableCmdlets
  2. Connect:

    $airtable = Connect-Airtable -APIKey "$APIKey" -BaseId "$BaseId" -TableNames "$TableNames" -ViewNames "$ViewNames"
  3. Search for and retrieve data:

    $column1 = "Value1" $sampletable_1 = Select-Airtable -Connection $airtable -Table "SampleTable_1" -Where "Column1 = `'$Column1`'" $sampletable_1

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

    $sampletable_1 = Invoke-Airtable -Connection $airtable -Query 'SELECT * FROM SampleTable_1 WHERE Column1 = @Column1' -Params @{'@Column1'='Value1'}

ADO.NET

  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.Airtable.AirtableConnection("APIKey=keymz3adb53RqsU;BaseId=appxxN2fe34r3rjdG7;TableNames=TableA,...;ViewNames=TableA.ViewA,...;") $conn.Open()
  3. Instantiate the AirtableDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Id, Column1 from SampleTable_1" $da= New-Object System.Data.CData.Airtable.AirtableDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.id $_.column1 }