Powershell Get item of html dropdown?

Hi,

This is exactly what I want to do:
https://stackoverflow.com/questions/15150397/powershell-select-drop-down-menu-from-web-page 

= selecting an item in a dropdown list of html (reporting server)

Now my link is
http://OurReportingServer/Reports/Pages/Report.aspx?ItemPath=%2fConfigMgr_PRD%2fSoftware+Updates+-+C+Deployment+States%2fStates+1+-+Enforcement+states+for+a+deployment

And what I want to be selected is
($dropdown | where {$_.innerHTML -like "Updates - PILOT*"}).Selected = $true

How can I achieve this?
J.
janhoedtAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jose Gabriel Ortega CEE Solution Guide - CEO Faru Bonon ITCommented:
Can you post the HTML file? and remove all the not relevant information for it like enterprise number change them for dummies and post the HTML file. We can do web scrapping for nothing, the link doesn't open.

We need at least the ID of the dropdown
0
oBdACommented:
Try this:
$ReportUrl = 'http://OurReportingServer/Reports/Pages/Report.aspx?ItemPath=%2fConfigMgr_PRD%2fSoftware+Updates+-+C+Deployment+States%2fStates+1+-+Enforcement+states+for+a+deployment'
$DropdownText = 'Updates - PILOT*'

$ie = New-Object -ComObject 'InternetExplorer.Application'
$ie.Visible = $true
$ie.Navigate($ReportUrl)
While ($ie.Busy) {Start-Sleep -Milliseconds 500}
$Option = $ie.Document.getElementsByTagName('OPTION') | Where-Object {$_.text -like $DropdownText}
$Option.selected = $true
While ($ie.Busy) {Start-Sleep -Milliseconds 500}
$Submit = $ie.Document.getElementsByTagName('INPUT') | Where-Object {$_.type -eq 'submit'}
$Submit.click()

Open in new window

2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
janhoedtAuthor Commented:
Works great! However, the selection method should be different because the text appears to be  (in the result of the query)
"Updates - PILOT - November - Updates - PILOT - November", so it is there twice and when selecting this $Option the submit does not find it.
Don't know why the text does this (enumerating twice) but tried to select on value

Tried  $option =  $($ie.Document.getElementsByTagName('OPTION') | Where-Object {$_.text -like $DropdownText}).uniquenumber but that does not work

Any ideas?
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

janhoedtAuthor Commented:
I see there is an option $option.uniqueNumber  but not suer how to fit this all together.
0
oBdACommented:
Sorry, can't quite follow your description of what's happening.
Does the script produce any errors, or is just IE / the site not cooperating?
What's the output when you just paste the following into a PS console?
$ReportUrl = 'http://OurReportingServer/Reports/Pages/Report.aspx?ItemPath=%2fConfigMgr_PRD%2fSoftware+Updates+-+C+Deployment+States%2fStates+1+-+Enforcement+states+for+a+deployment'
$DropdownText = 'Updates - PILOT*'
$ie = New-Object -ComObject 'InternetExplorer.Application'
$ie.Visible = $true
$ie.Navigate($ReportUrl)
While ($ie.Busy) {Start-Sleep -Milliseconds 500}
$Option = $ie.Document.getElementsByTagName('OPTION') | Where-Object {$_.text -like $DropdownText}
$Option | select inner*, outer*, text

Open in new window

1
janhoedtAuthor Commented:
Never mind, overlooked something. Works great, thanks a lot!
0
janhoedtAuthor Commented:
Sidenote: any idea howto make this possible in an htlml only context (so <a> </a>)?
0
oBdACommented:
Similar to the above, only the TagName would be "A".
1
janhoedtAuthor Commented:
Think you misunderstood. I'd need to make a webpage which is generated by Powershell. The link itself should point to the url which triggers the dropdownbox and submits.
Probably some javascript or something else to include into the webpage?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.