views:

33

answers:

3

How can i access document property of already running explorer processes. i am using following line of code to get process.

$ie2 = Get-Process |where {$.mainWindowTItle -eq "Windowtitletext"} | where {$.ID -ne $ieParentProcessNumber}

now i want to do some processing on this processes like $ie2.Document etc.

A: 

If you know that you'll receive 1 object:

(Get-Process explorer).CPU

If you want to know what are the available properties:

Get-Process explorer | Get-Member

If you have more than one object in your result set (e.g. Get-Process returning mutiple processes mathing search criteria):

Get-Process | Where-Object { $_.Handles -ge 200 } | Foreach-Object { $_.CPU }
Non Blocking
+1  A: 

It seems like you are trying to access the Document (i.e a webpage's data) directly from the process. This is not possible using the get-process.

You would need to create a instance of a IE com object for example or use the System.Net.WebClient if you want to just read data from a web site. Post more info about what you are trying to do and we can possibly help you out better

RC1140
In Short : I am trying to get document of a popup window. Description: I have asp.net page with a hyperlink when i click on that link it calls javascript __dopostback event which shows a popup window and on that popup window i have option to download that zip file. the problem i am facing right now is that when i call click event in powershell a new iexplorer process is started (for popup window) how can i get document of that popup window and click on it.
Doing this pureley with powershell might be a bit of a pain , rather use something like Watin + Powershell. Or you can try using send keys to the active window to perform what ever operation you want
RC1140
+1  A: 

You can attach to the ie window:

$app = New-Object -ComObject shell.application
$popup = $app.Windows() | where {$_.LocationName -like "*foo*"}
$popup.document
Shay Levy