Technical Article Introducing PoshBing – The PowerShell library for Microsoft’s Bing Search Engine June 03, 2009 by Joe Pruitt 5813 article applications hardware industry microsoft partner powershell us 0 Microsoft released their new search engine called “Bing” at, aptly named, http://www.bing.com. Microsoft is getting positive reviews from the likes of CNET, The Wall Street Journal, and TechCrunch. Instead of posting my review of the site, I’ll let you browse the above links to find out what the services is all about. What interested me about Bing is that Microsoft has released a full API to allow you to use their services in your applications. The Bing API is documented at Microsoft’s developer site and I thought to myself how I could test it out. The obvious answer was PowerShell of course. My previous PoshTweet Twitter Library has been fairly popular so I figured I’d give a “library” type project another go around and tackle the Bing APIs. The Bing API has the concept of “SourceTypes” which are essentially data sources that you can search into. My script library provides access to the Image, InstantAnswer, News, MobileWeb, Phonebook, RelatedSearch, Spell, Web, Translation, and Video SourceTypes with the following functions: Get-BingImage – Search the Image SourceType for a list of images including properties about the media files. Get-BingInstantAnswer – Get single, authoritative answers to questions. Get-BingNews – Provide news specific to a topic, a location, or breaking news. Get-BingMobileWeb – Returns mobile web results, primarily relevant XHTML or WML pages. Get-BingPhonebook – Enables you to view details about a business for which you are searching as if they were a phonebook entry. Get-BingRelatedSearch – View searches that provide information in which you might be interested, based on your current search. Get-BingSpell – Query alternative spellings for a given word or phrase. Get-BingWeb – Get pages relevant to the queried terms. Get-BingTranslation – Translate a term from one language to another. Get-BingVideo – return a list of videos and their properties relevant to the query terms. I’ve included parsing for the response streams for the above SourceTypes, but if you would like to get the raw XML back, all of the above functions include a “-raw” parameter to allow you to bypass the response processing. *Update* This little script has taken on a life of it’s own. As a consequence, I’ve created a project on CodePlex.com to manage the distributions. You can access it now at the following link: http://poshbing.codeplex.com Enjoy! last modified: June 05, 2009 9 Comment(s): 0 Jamie, have you checked out @askbing on twitter? I combined my PoshBing and PoshTweet libraries into a PowerShell twitter bot.Thanks for the linking as well!-Joe 0 Jamie, you can try lowering your execution policy with "Set-ExecutionPolicy Unrestricted" and see if that helps.I'll look into signing the script when it get's to production level.Once you have . sourced the file, you shouldn't get security warnings when trying to execute the functions.-Joe 0 Glad you figured it out. There's a space between the first "." and the .\PoshBing.ps1. Type "help about_scope" at the PowerShell prompt for more details on dot sourcing a file.-Joe 0 PS> .\PoshBing.ps1 will run the script. Since there are only function declarations inside the script and no actual commands, just running the .ps1 will not do anything. You need to "dot source" the file which basically loads all the definitions into your current runspace.PS> . .\PoshBing.ps1If you get a warning about trusted scripts, you may need to set your execution policy down with "Set-ExecutionPolicy Unrestricted". I probably should sign this script so that folks don't get that error...Let me know if this does or doesn't work for you.-Joe 0 Sorry about that. Comment out the Export-ModuleMember or download the latest version.-Joe 0 Should be good to go now. Get-BingNews "FFIV" | out-gridview now works B-). Thanks for the feedback!!!-Joe 0 @Hal, I've already made a bunch of those changes and write-host is gone from my current code. That's the problem with getting things out early... I'll post when I've got the object-based output finalized.-Joe 0 @Doug - No reason, just figured since it's values were true of false, I'd use a boolean.-Joe 0 @Geri-Tore Lindsve - Another options to just "dot source" the script file. PS> . .\PoshBing.ps1 That will load all the functions into your current runspace. If you want them always available you can . source it in your $profile as well.-Joe You must be logged in to post comments.