< Back

Search-Bing

Sun Jan 19, 2020 5:35 pm

NAME Search-Bing



SYNOPSIS

Bing search based on query.





SYNTAX

Search-Bing [-Query] <String> [[-Count] <Int32>] [-SafeSearch <String>] [<CommonParameters>]





DESCRIPTION

This cmdlet returns Bing web search results Using Microsoft cognitive service's "Bing Search" API, by issuing an

HTTP GET request to the API

NOTE : You need to subscribe the "Bing search API" before using the powershell script from the following link and

setup an environment variable like, $env:MS_BingSearch_API_key = "YOUR API KEY"



API Subscription Page - https://www.microsoft.com/cognitive-ser ... us/sign-up





PARAMETERS

-Query <String>

String you want to search on Bing



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Count <Int32>

Number of results you want Bing Search to return



Required? false

Position? 2

Default value 10

Accept pipeline input? false

Accept wildcard characters? false



-SafeSearch <String>

Safe search to avoid adult content to be returned from Bing search, default value is set to 'Moderate'



Required? false

Position? named

Default value Moderate

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Author: Prateek Singh - @SinghPrateik



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Search-Bing -Query "Bill Gates" -Count 2



Query : Bill Gates

Result : Bill Gates - Wikipedia, the free encyclopedia

URL : https://en.wikipedia.org/wiki/Bill_Gates

Snippet : William Henry "Bill" Gates III (born October 28, 1955) is an American business magnate,

entrepreneur, philanthropist, investor, and programmer. In 1975, Gates and

Paul Allen co-founded Microsoft, which became the world's largest PC software company.

DateLastCrawled : 2016-06-24



Query : Bill Gates

Result : Bill Gates - Biography.com

URL : www.biography.com/people/bill-gates-9307520

Snippet : Biography.com tracks the life and career of Bill Gates, from his early interest in computer

programming to his place as founder of Microsoft, the world's largest

software business.

DateLastCrawled : 2016-06-20





In above example, I ran a bing search on "Bill gates" and chose to return only 2 matching results values.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Search-Bing -Query "Bill Gates" -Count 1 -SafeSearch Strict



Query : Bill Gates

Result : Bill Gates - Wikipedia, the free encyclopedia

URL : https://en.wikipedia.org/wiki/Bill_Gates

Snippet : William Henry "Bill" Gates III (born October 28, 1955) is an American business magnate,

entrepreneur, philanthropist, investor, and programmer. In 1975, Gates and

Paul Allen co-founded Microsoft, which became the world's largest PC software company.

DateLastCrawled : 2016-06-24



You can choose different modes (Strict, Moderate, Off) in '-SafeSearch' to make sure no adult content is returned

from the Bing Search











RELATED LINKS