title: Execute javascript trough Internet Explorer's com interface using PowerShell
body: <p>I am writing some Internet Explorer automation scripts using PowerShell. Here is how I start the IE com object:</p>
  
  <pre><code>$ie = New-Object -com "InternetExplorer.Application"
  $ie.Navigate("about:blank")
  $ie.visible = $true
  
  $doc = $ie.Document
  </code></pre>
  
  <p>So, what I would like to do is to execute some javascript on the <code>$doc</code> object. For example, I have an item on the page that has an <code>onclick</code> event which executes <code>submitCommand('lookup')</code>, so I'd like to run that directly on the <code>$doc</code> instead of having to find the object on the page and then calling the <code>Click()</code> method on it.</p>
  
  <p>It would be easier as the object has no name nor id, making it very sensible to change as I can only rely on it's position on the page (eg: the 11th span item on the page).</p>
  
  <p>Alternatively, how would you select elements based on their class? That would help a lot as the "button" has it's own class.</p>
  
  <p>Thanks</p>