October 30, 2014

Send commands to IE from Powershell

Filed under: Tips — donrsh @ 11:24 am

The below code is just a sample code. Modify it…
It starts the IE, logging to “site” and doing some clicking.

$ie = New-Object -com internetexplorer.application;
$ie.visible = $true;
while ($ie.Busy -eq $true)
Start-Sleep -Milliseconds 1000;

$ie.Document.getElementById("user_name").value = $username
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('Internet Explorer')
Sleep 3
Start-Sleep -Milliseconds 1000
$link = @($ie.Document.getElementsByTagName('A')) | Where-Object {$_.innerText -eq 'select site'}
Sleep 3
sleep 3
$linkpage2 = @($ie.Document.getElementsByTagName('A')) | Where-Object {$_.innerText -eq 'Logoff'}
Sleep 5
Get-Process -Name iexplore | Stop-Process

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: