Advertisement
Guest User

Untitled

a guest
Jul 17th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function search-custom() {
  2.     Param(
  3.         [Parameter(Mandatory = $true)][string]$search,
  4.         [AllowEmptyString()] $customsearch_id = "006759091738829999417%3A-ynq7qhchoc",
  5.         [AllowEmptyString()]$api_key="<your key>"
  6.     )
  7.    
  8.     try {
  9.     $Search_results = invoke-restmethod "https://www.googleapis.com/customsearch/v1?q=$search&cr=us&cx=$customsearch_id&key=$api_key"
  10.     $search_results = ($search_results.items) | select title, snippet,link
  11.     return $search_results
  12.     } catch {
  13.     return $false
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement