Friday Fun: Search Me

magnifying-glass-text-label-search I’ve been working on a few revisions and additions to my ISE Scripting Geek module. Even though what I’m about to show you will eventually be available in a future release of that module, I thought I’d share it with you today. One of the things I wanted to be able to do was search Google (or Bing) from within the PowerShell ISE.

If you research search techniques or APIs for sites like Google and Bing, you’ll quickly get swallowed up in the miasma of JSON, SOAP, XML and mind-numbing examples. Although you might enjoy this sort of thing, I was hoping to find something much, much simpler. After all, I’m not going to be creating complicated search queries. I’m going to want to search for a simple term or phrase like “powershell remoting” or “Invoke-Webrequest”.

For Google, it is this simple to create a URL:

To use Bing, it seems it helps to include your culture which you can retrieve with Get-Culture.

In either case I now have an appropriate URL ready to go into my default browser. I can’t guarantee this will work for everyone, but it is as simple as this command:

I’m actually using the alias for Start-Process but in this case I don’t mind. Windows will switch to my browser and open the URL in a new tab. To make all of this a bit more flexible I put together a simple function.

The function needs a string of text to search for and a search engine. I’ve set a default to Google. You’ll also see that I’ve included parameter validation so that you can only use a value in a pre-defined set. To make the function a bit more interesting I also included Yahoo. I’ve used a Switch statement to determine how to construct the url. You could use this function from either the console or the PowerShell ISE. I suppose in terms of PowerShell this is a “low-tech” approach but it works and meets my needs.

To plug this into the ISE, you need to dot source the function in the ISE. Then if you want, you can add it as a menu item.

This will add a menu shortcut to the Add-Ons menu called “Search Internet”. I’ve also included an optional keyboard shortcut ALT+S, but you can define anything that isn’t already being used. When the menu item is invoked, it will run my Get-SearchResult function and use the currently selected text for the -Text parameter. The net result is a Google search for whatever I have selected in a script file. If you prefer Bing, I’d simply modify the function and set it as the default.

This isn’t rocket science but hopefully makes your PowerShell experience a little more efficient. You are welcome to try this now, or wait for the next version of the ISE Scripting Geek.

Have a great weekend.

Friday Fun: Updated ISE Scripting Geek Module

geek A few years ago I published a module with a number of functions and enhancements for the PowerShell ISE. This ISEScriptingGeek module has remained popular over the last few years. But I wrote it for PowerShell v2. I have also come up with a number of new additions to the ISE that I use to make scripting easier. So I have gone ahead and updated the module.

The new module includes most of the original features, many of which are added to a custom add-ons menu.

scriptinggeek-addon-menu

To use the module, import it in the ISE or in your ISE profile script. Once imported you can view all of the commands.

Most of the commands will have help. I’m not going to go into detail about every command and menu option. I incorporated my scripting help module as well to provide documentation on some of the validation attributes. I think you should load up some test files and try things out.

The final thing I have done is to include some ISE theme files. To import them, go to Tools – Options and click on Manage Themes. Click on Import and navigate to the Themes folder in the module directory (…\documents\WindowsPowerShell\Modules\ISEScriptingGeek\Themes). You should see 3 files. Import one or more, select it and click OK.

grayscaletheme

monoyellow-theme

vim-themeIf you have questions or run into a problem, feel free to post a comment. I especially would love to hear about your favorite features from the module.

This version requires PowerShell 4.0 or later. You can download an older version directly here: ISEScriptingGeek-v3.1 and extract to your modules directory.

UPDATE August 2015: I have moved this project to GitHub to make it easier to update and maintain. You can check it out at https://github.com/jdhitsolutions/ISEScriptingGeek along with my other projects.

 

Enjoy and happy scripting.

ISE Scripting Geek Module

Over the last year I’ve posted functions I’ve written to extend the Windows PowerShell ISE. I have finally pulled everything together into a module I’m calling the ISE Scripting Geek. Download and extract the zip file (below) to your modules folder. You should end up with a path like ‘C:\Users\Jeff\Documents\WindowsPowerShell\Modules\ISEScriptingGeek’.

In the ISE, import the module:

Or do as I did and add it to your Powershell ISE profile script. The module will add an ISE Scripting Geek menu add on.

ISE Scripting Geek add-on menu
Here you will find my tools for printing a script, signing a script, converting aliases to commands (and vice versa) and a few other goodies. I’ve also included my function to keep track of most recently used scripts. If you don’t want to use some of the tools, edit the psm1 file and comment out what you don’t want. If there’s something you’d like to see, let me know. No promises but I might have something stashed away.

[shameless plug] If you want to look cool as well check out www.ScriptingGeek.com

Download ISEScriptingGeek

UPDATE: A revised version of this module for PowerShell 4.0 and later is now available at http://bit.ly/14aGnLq

ScriptingGeek Savings This Weekend

This weekend you can save some money on gear and tees from ScriptingGeek.com.

Coupon Code: StarSavings
Discount: $5 off any order!

Coupon Code: BrightSavings
Discount: $10 off subtotal of $50+

Coupon Code: SpangledSavings
Discount: $30 off subtotal of $100+

Disclaimer: Please enter coupon code StarSavings, BrightSavings, or SpangledSavings before completing checkout. Discount is applied to the base price and does not include shipping, taxes, or additional charges. Email us if you have questions. This offer may not be combined with other offers. Coupons valid from 6/29/2011 to 7/5/201111:59 pm Mountain Time.

Visit www.ScriptingGeek.com to get started.

ScriptingGeek Free Shipping until May 3

I’m happy to report that from now until Tuesday May 3rd, 2011 at 11:50PM Mountain Standard Time, you can get free shipping from www.ScriptingGeek.com on orders over $30. ScriptingGeek.com has a selection of script-related t shirts, sweatshirts, hoodies, mugs and more. Be proud and show the world and your colleagues just how much of a scripting geek you really are! This is a great time to stock up before TechEd.

Here’s the fine print and details on the free shipping offer.

Coupon Code: ShipmeforFREE

Discount: Free Super Saver, Canadian or International Airmail on orders with a subtotal of $30+

Dates: Friday, April 29 to Tuesday, May 3

Disclaimer: Please enter coupon code ShipmeforFREE before completing checkout. Discount applies only to Super Saver, Canadian or International Airmail shipments with a subtotal of $30+. May not be combined or substituted with any other promotion. Discount does not include products, taxes, or additional charges. Orders under this promotion may be delayed. Coupons valid from 4/29/2011 to 5/3/2011 11:59 pm Mountain Time.