Automate Google Search Integration Tasks from PowerShell
The CData ADO.NET Provider for Google Search 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 Search.
ADO.NET Provider
The ADO.NET Provider provides a SQL interface for Google Search; this tutorial shows how to use the Provider to retrieve Google Search results.
Once you have acquired the necessary connection properties, accessing Google Search results in PowerShell can be enabled in three 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.
-
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") -
Connect to Google Search:
$conn= New-Object System.Data.CData.GoogleSearch.GoogleSearchConnection("CustomSearchId=def456;ApiKey=abc123;") $conn.Open() -
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 }