Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →Automate Bing Search Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Bing Search results from PowerShell? This article demonstrates how to utilize the Bing Search Cmdlets for tasks like connecting to Bing Search results, automating operations, downloading data, and more.
The CData Cmdlets for Bing 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 Bing Search.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Bing Search, but also an SQL interface; this tutorial shows how to use both to retrieve Bing Search results. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Bing Search. To access Bing Search results from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Bing Search.
Once you have acquired the necessary connection properties, accessing Bing Search results in PowerShell can be enabled in three steps.
To connect to Bing, set the ApiKey connection property. To obtain the API key, sign into Microsoft Cognitive Services and register for the Bing Search APIs.
Two API keys are then generated; select either one.
When querying tables, the SearchTerms parameter must be supplied in the WHERE clause.
PowerShell
-
Install the module:
Install-Module BingCmdlets
-
Connect:
$bing = Connect-Bing -APIKey "$APIKey"
-
Search for and retrieve data:
$searchterms = "WayneTech" $videosearch = Select-Bing -Connection $bing -Table "VideoSearch" -Where "SearchTerms = `'$SearchTerms`'" $videosearch
You can also use the Invoke-Bing cmdlet to execute SQL commands:
$videosearch = Invoke-Bing -Connection $bing -Query 'SELECT * FROM VideoSearch WHERE SearchTerms = @SearchTerms' -Params @{'@SearchTerms'='WayneTech'}
ADO.NET
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Bing Search\lib\System.Data.CData.Bing.dll")
-
Connect to Bing Search:
$conn= New-Object System.Data.CData.Bing.BingConnection("APIKey=MyAPIKey;") $conn.Open()
-
Instantiate the BingDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Title, ViewCount from VideoSearch" $da= New-Object System.Data.CData.Bing.BingDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.title $_.viewcount }