Automate Google Search Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Google Search ADO.NET Provider

Easy-to-use Google search client enables .NET-based applications to easily search Google and filter search results.

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

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

Cmdlets or ADO.NET?

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

After obtaining the needed connection properties, accessing Google Search results in PowerShell consists of three basic steps.

To search with a Google custom search engine, you need to set the CustomSearchId and ApiKey connection properties.

To obtain the CustomSearchId property, sign into Google Custom Search Engine and create a new search engine.

To obtain the ApiKey property, you must enable the Custom Search API in the Google API Console.


  1. Install the module:

    Install-Module GoogleSearchCmdlets
  2. Connect:

    $googlesearch = Connect-GoogleSearch -CustomSearchId "$CustomSearchId" -ApiKey "$ApiKey"
  3. Search for and retrieve data:

    $searchterms = "WayneTech" $videosearch = Select-GoogleSearch -Connection $googlesearch -Table "VideoSearch" -Where "SearchTerms = `'$SearchTerms`'" $videosearch

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

    $videosearch = Invoke-GoogleSearch -Connection $googlesearch -Query 'SELECT * FROM VideoSearch WHERE SearchTerms = @SearchTerms' -Params @{'@SearchTerms'='WayneTech'}


  1. Load the provider's assembly:

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

    $conn= New-Object System.Data.CData.GoogleSearch.GoogleSearchConnection("CustomSearchId=def456;ApiKey=abc123;") $conn.Open()
  3. Instantiate the GoogleSearchDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Title, ViewCount from VideoSearch" $da= New-Object System.Data.CData.GoogleSearch.GoogleSearchDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.title $_.viewcount }