I am new to powershell, and am trying to write a script that opens Internet Explorer, navigates to a page, then searches that page for a string of text. Here is the beginning of my code, I just can't seem to figure out how to search the hidden page once it opens for a string of text, such as "EXAMPLE"
$ie = New-Object -com InternetExplorer.Application
Any help would be greatly appreciated.
Are you fixed on using Internet Explorer for this? You'd have an easier time using Invoke-WebRequest, in PowerShell. For example:
$response = Invoke-WebRequest -Uri 'http://www.example.com'
$response will be a [Microsoft.PowerShell.Commands.HtmlWebResponseObject] object which has lots of useful properties. $response.Content will give you the page's raw HTML code. The AllElements, Forms, Headers, Images, InputFields and Links properties give you access to information about the HTML tags found on the page.
$response.ParsedHtml will be a reference to a COM object that lets you access the HTML DOM model directly (though I'll warn you, this is very slow in PowerShell for some reason. Use the other properties if they'll get the job done for you.) For instance, you could execute $response.ParsedHtml.documentElement.getElementsByTagName('table')
You must be logged in to reply to this topic.