July'06

PowerShell and Internet Explorer

Powershell is a wonderfull tool to play and invoke -com objects. Here let us see some powershell ways to start a internet explorer and navigate to a url

PS C:\> $ie = New-Object -comobject InternetExplorer.Application    #This will Start a new Internet Explorer Process

$ie.visible = $true   # This will make the application visible (if needeed)

Now that we launced an internet explorer, lets navigate to a URL.

PS C:\> $url = “www.google.com”    # Specified url in advance

PS C:\> $ie.Navigate($url)   # This will make IE to navigate to specified URL

 Getting text of the html page opened

lets put the content to a variable.

PS C:\> $doc = $ie.Document  # setting ie.document content to a variable

To get the Inner text out of the HTML Document BODY

PS C:\> $doc.body.innertext

We can explore more methods by piping to Get-member parameter

Example…

PS C:\> $doc | get-member

 We can also connect to registry of a remote machine using Wmi methods through POWERSHELL

Take a look at this article http://www.microsoft.com/technet/scriptcenter/topics/msh/mshandwmi.mspx 

Advertisements
Standard

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s