Get process ID from Com Object

LaPhi picture LaPhi · Nov 29, 2010 · Viewed 8.9k times · Source

It is possible to get the Process ID from this new Com Object ($ie) ?

$ie=New-Object -comobject InternetExplorer.Application  
$ie.visible=$true  
$ie.Navigate("www.stackoverflow.com")

Answer

Dirk Vollmar picture Dirk Vollmar · Nov 29, 2010

The following will give you the parent IE process:

(Get-Process -Name iexplore)| Where-Object {$_.MainWindowHandle -eq $ie.HWND}