Last active
December 11, 2015 20:08
-
-
Save mwjcomputing/4652855 to your computer and use it in GitHub Desktop.
This is an update to jwgoerlich's Search-Chrome Function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Search-Chrome { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true, ValueFromPipeline=$true)] | |
[string]$Search | |
) | |
begin { | |
Write-Verbose -Message "Starting $($MyInvocation.Mycommand)" | |
Write-Verbose -Message "Loading System.Web .NET Class" | |
$null = [Reflection.Assembly]::LoadWithPartialName("System.Web") | |
Write-Verbose -Message "Setting searchString to null" | |
$searchString = $null | |
} | |
process { | |
Write-Verbose "Encoding $Search into a URL Friendly string." | |
$searchString = [System.Web.HttpUtility]::UrlEncode("$Search") | |
Write-Verbose -Message "Starting Google Chrome to search for $searchString" | |
Start-Process -FilePath chrome.exe -ArgumentList "http://www.google.com/search?q=$searchString" | |
} | |
end{ | |
Write-Verbose -Message "Ending $($MyInvocation.Mycommand)" | |
} | |
<# | |
.SYNOPSIS | |
This script launches Google Chrome and searchers for the specified term. | |
.DESCRIPTION | |
This script uses Start-Process to launch Google Chrome and searches for the user specified search string. | |
.PARAMETER Search | |
The search term. | |
.EXAMPLE | |
PS C:\> Search-Chrome -Search "mwjcomputing" | |
.EXAMPLE | |
PS C:\> Search-Chrome -Search "BSides Detroit 2013" | |
.EXAMPLE | |
PS C:\> "Test1", "Test2" | Search-Chrome | |
.INPUTS | |
System.String | |
.OUTPUTS | |
Null | |
.NOTES | |
This script was my modification to Wolfgang Goerlich's (@jwgoerlich) Search-Chrome function. | |
http://pastebin.com/a4XkRRWZ | |
.LINK | |
www.mwjcomputing.com | |
.LINK | |
www.twitter.com/mwjcomputing | |
#> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment