Automate Google Campaign Manager Integration Tasks from PowerShell

Ready to get started?

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

 Download Now

Learn more:

DoubleClick Campaign Manager Icon DoubleClick ADO.NET Provider

An easy-to-use database-like interface for .NET applications access to live DoubleClick Campaign Manager data (Ads, Accounts, Creatives, Orders, and more).

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

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

PowerShell Cmdlets or ADO.NET Driver?

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

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

Google Campaign Manager uses the OAuth authentication standard. The data provider facilitates OAuth in various ways as described below. The following OAuth flow requires the authenticating user to interact with DoubleClick Campaign Manager, using the browser. You can also use a service account to authenticate.

For authentication guides, see the Getting Started section of the data provider help documentation.


  1. Install the module:

    Install-Module GoogleCMCmdlets
  2. Connect:

    $googlecm = Connect-GoogleCM -UserProfileID "$UserProfileID"
  3. Search for and retrieve data:

    $device = "Mobile devices with full browsers" $campaignperformance = Select-GoogleCM -Connection $googlecm -Table "CampaignPerformance" -Where "Device = `'$Device`'" $campaignperformance

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

    $campaignperformance = Invoke-GoogleCM -Connection $googlecm -Query 'SELECT * FROM CampaignPerformance WHERE Device = @Device' -Params @{'@Device'='Mobile devices with full browsers'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.GoogleCM.GoogleCMConnection("UserProfileID=MyUserProfileID;InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the GoogleCMDataAdapter, execute an SQL query, and output the results:

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

Update Google Campaign Manager Data


Update-GoogleCM -Connection $GoogleCM -Columns @('Clicks','Device') -Values @('MyClicks', 'MyDevice') -Table CampaignPerformance -Id "MyId"


$cmd = New-Object System.Data.CData.GoogleCM.GoogleCMCommand("UPDATE CampaignPerformance SET Device='Mobile devices with full browsers' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.GoogleCM.GoogleCMParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Google Campaign Manager Data


Add-GoogleCM -Connection $GoogleCM -Table CampaignPerformance -Columns @("Clicks", "Device") -Values @("MyClicks", "MyDevice")


$cmd = New-Object System.Data.CData.GoogleCM.GoogleCMCommand("INSERT INTO CampaignPerformance (Device) VALUES (@myDevice)", $conn) $cmd.Parameters.Add(new System.Data.CData.GoogleCM.GoogleCMParameter("@myDevice","Mobile devices with full browsers")) $cmd.ExecuteNonQuery()

Delete Google Campaign Manager Data


Remove-GoogleCM -Connection $GoogleCM -Table "CampaignPerformance" -Id "MyId"


$cmd = New-Object System.Data.CData.GoogleCM.GoogleCMCommand("DELETE FROM CampaignPerformance WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.GoogleCM.GoogleCMParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()