djsnakz
djsnakz

Reputation: 478

PowerShell Web Request from table

I have an issue where I am attempting to pass information from a table in PowerShell into a URL but am not having any luck doing so.

$Content = Get-Content "C:\Utilities\Content.txt" -Raw
$ie = New-Object -ComObject InternetExplorer.Application
$line = Select-String "c:\utilities\Content.txt" -pattern ", ([A-Z])\w+ [[\d]{4}" -AllMatches | Select Line

$ie.Navigate("https://www.testurl.com/$line[1]")

I am attempting to pull information from the table with $line[1] or [2] for example and navigate to that address in the $ie.navigate command. When I call the command $line[1] I get back the information I require (although it comes with the the word "Line" above it ie:"

Line                                                                                                                                                                                                                                                                                                                                                      
----                                                                                                                                                                                                                                                                                                                                                      
Useful Information in this line here

although it does not appear to be accepting the variable inside the Navigate Method. Is it possible by having it in a table like this its not reading it correctly when i attempt to pass that information off the to Navigate Method? Any point in the right direction would be very helpful.

Upvotes: 0

Views: 87

Answers (1)

Peter Schneider
Peter Schneider

Reputation: 2929

Correct your $ie.Navigate line to the following $ie.Navigate("https://www.testurl.com/$($line[1])")

Upvotes: 1

Related Questions