title: Script to open webpage and search
body: <p>I am trying to write a PowerShell script to open up a window in chrome, go to google, enter text in the search bar, hit enter, and then retrieve all the links in an array. Here's my first attempt at the code:</p>
  
  <pre><code>$URI = "www.google.com"
  $HTML = Invoke-WebRequest -Uri $URI
  $SearchField = $HTML.ParsedHtml.getElementById('lst-ib')
  $SearchField.value = "green flowers"
  $SearchButton = $HTML.ParsedHtml.getElementsByName('btnK')
  $SearchButton.click();
  //Grab links and store into array
  </code></pre>
  
  <p>But when I try to run it I get this:</p>
  
  <pre>The property 'value' cannot be found on this object. Verify that the property
  exists and can be set.
  At line:4 char:1
  + $SearchField.value = "green flowers"
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : PropertyAssignmentException
  
  Method invocation failed because [System.DBNull] does not contain a method named
  'click'.
  At line:6 char:1
  + $SearchButton.click();
  + ~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
      + FullyQualifiedErrorId : MethodNotFound</pre>