Automate Google Ads Integration Tasks from PowerShell

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

The CData ADO.NET Provider for Google Ads 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 Google Ads.

ADO.NET Provider

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

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

Google uses the OAuth authentication standard. To access Google APIs on behalf on individual users, you can use the embedded credentials or you can register your own OAuth app.

OAuth also enables you to use a service account to connect on behalf of users in a Google Apps domain. To authenticate with a service account, register an application to obtain the OAuth JWT values.

In addition to the OAuth values, specify the DeveloperToken and ClientCustomerId.

See the "Getting Started" chapter of the help documentation for a guide to using OAuth.

  1. Load the provider's assembly:

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

     
    $conn= New-Object System.Data.CData.GoogleAds.GoogleAdsConnection("DeveloperToken=MyDeveloperToken;ClientCustomerId=MyClientCustomerId;InitiateOAuth=GETANDREFRESH;")
    $conn.Open()
    
  3. Instantiate the GoogleAdsDataAdapter, execute an SQL query, and output the results:

    
    $sql="SELECT Device, Clicks from CampaignPerformance"
    
    $da= New-Object System.Data.CData.GoogleAds.GoogleAdsDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
    	Write-Host $_.device $_.clicks
    }
      

Ready to get started?

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

 Download Now

Learn more:

Google AdWords Icon Google AdWords ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Google Ads data including Campaigns, AdGroups, Performance, and more!